Your IP : 192.168.165.1


Current Path : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/
Upload File :
Current File : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/competencypicker_user_plans.min.js.map

{"version":3,"sources":["../src/competencypicker_user_plans.js"],"names":["define","$","Notification","Ajax","Templates","Str","Tree","PickerBase","Picker","userId","singlePlan","multiSelect","prototype","constructor","apply","_userId","_plans","_planId","_singlePlan","Object","create","_afterRender","self","arguments","_find","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","_fetchCompetencies","planId","searchText","call","methodname","args","id","done","competencies","i","comp","tree","length","competency","shortname","toLowerCase","indexOf","children","haschildren","push","_competencies","fail","_getPlan","plan","each","f","_searchText","_loadPlans","promise","when","userid","plans","_preRender","_render","selected","context","search","render"],"mappings":"AA4BAA,OAAM,uCAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,gBAHD,CAIC,UAJD,CAKC,cALD,CAMC,0BAND,CAAD,CAQE,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAgDC,CAAhD,CAAsDC,CAAtD,CAAkE,CAStE,GAAIC,CAAAA,CAAM,CAAG,SAASC,CAAT,CAAiBC,CAAjB,CAA6BC,CAA7B,CAA0C,CACnDJ,CAAU,CAACK,SAAX,CAAqBC,WAArB,CAAiCC,KAAjC,CAAuC,IAAvC,CAA6C,CAAC,CAAD,IAAW,MAAX,CAAmBH,CAAnB,CAA7C,EACA,KAAKI,OAAL,CAAeN,CAAf,CACA,KAAKO,MAAL,CAAc,EAAd,CAEA,GAAIN,CAAJ,CAAgB,CACZ,KAAKO,OAAL,CAAeP,CAAf,CACA,KAAKQ,WAAL,GACH,CACJ,CATD,CAUAV,CAAM,CAACI,SAAP,CAAmBO,MAAM,CAACC,MAAP,CAAcb,CAAU,CAACK,SAAzB,CAAnB,CAGAJ,CAAM,CAACI,SAAP,CAAiBI,MAAjB,CAA0B,IAA1B,CAE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C0D,IAAF,CAAOrC,CAAI,CAACN,MAAZ,CAAoB,SAAS4B,CAAT,CAAYc,CAAZ,CAAkB,CAClC,GAAIA,CAAI,CAACjB,EAAL,EAAWnB,CAAI,CAACL,OAApB,CAA6B,CACzByC,CAAI,CAACW,QAAL,GACH,CAFD,IAEO,CACHX,CAAI,CAACW,QAAL,GACH,CACJ,CAND,CAOH,CAED,GAAIC,CAAAA,CAAO,CAAG,CACV3B,YAAY,CAAErB,CAAI,CAACiC,aADT,CAEVG,IAAI,CAAEpC,CAAI,CAACmC,QAAL,CAAcnC,CAAI,CAACL,OAAnB,CAFI,CAGViD,KAAK,CAAE5C,CAAI,CAACN,MAHF,CAIVuD,MAAM,CAAEjD,CAAI,CAACuC,WAJH,CAKVnD,UAAU,CAAEY,CAAI,CAACJ,WALP,CAAd,CAQA,MAAOd,CAAAA,CAAS,CAACoE,MAAV,CAAiB,sCAAjB,CAAyDF,CAAzD,CACV,CArBM,CAsBV,CAxBD,CA0BA,MAAgE9D,CAAAA,CAEnE,CArNK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Competency picker from user plans.\n *\n * To handle 'save' events use: picker.on('save').\n *\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @package    tool_lp\n * @copyright  2015 Frédéric Massart - FMCorz.net\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n        'core/notification',\n        'core/ajax',\n        'core/templates',\n        'core/str',\n        'tool_lp/tree',\n        'tool_lp/competencypicker'\n        ],\n        function($, Notification, Ajax, Templates, Str, Tree, PickerBase) {\n\n    /**\n     * Competency picker in plan class.\n     *\n     * @param {Number} userId\n     * @param {Number|false} singlePlan The ID of the plan when limited to one.\n     * @param {Boolean} multiSelect Support multi-select in the tree.\n     */\n    var Picker = function(userId, singlePlan, multiSelect) {\n        PickerBase.prototype.constructor.apply(this, [1, false, 'self', multiSelect]);\n        this._userId = userId;\n        this._plans = [];\n\n        if (singlePlan) {\n            this._planId = singlePlan;\n            this._singlePlan = true;\n        }\n    };\n    Picker.prototype = Object.create(PickerBase.prototype);\n\n    /** @type {Array} The list of plans fetched. */\n    Picker.prototype._plans = null;\n    /** @type {Number} The current plan ID. */\n    Picker.prototype._planId = null;\n    /** @type {Boolean} Whether we can browse plans or not. */\n    Picker.prototype._singlePlan = false;\n    /** @type {Number} The user the plans belongs to. */\n    Picker.prototype._userId = null;\n\n    /**\n     * Hook to executed after the view is rendered.\n     *\n     * @method _afterRender\n     */\n    Picker.prototype._afterRender = function() {\n        var self = this;\n        PickerBase.prototype._afterRender.apply(self, arguments);\n\n        // Add listener for framework change.\n        if (!self._singlePlan) {\n            self._find('[data-action=\"chooseplan\"]').change(function(e) {\n                self._planId = $(e.target).val();\n                self._loadCompetencies().then(self._refresh.bind(self))\n                .catch(Notification.exception);\n            });\n        }\n    };\n\n    /**\n     * Fetch the competencies.\n     *\n     * @param {Number} planId The planId.\n     * @param {String} searchText Limit the competencies to those matching the text.\n     * @method _fetchCompetencies\n     * @return {Promise} The promise object.\n     */\n    Picker.prototype._fetchCompetencies = function(planId, searchText) {\n        var self = this;\n\n        return Ajax.call([\n            {methodname: 'core_competency_list_plan_competencies', args: {\n                id: planId\n            }}\n        ])[0].done(function(competencies) {\n\n            // Expand the list of competencies into a fake tree.\n            var i, comp;\n            var tree = [];\n            for (i = 0; i < competencies.length; i++) {\n                comp = competencies[i].competency;\n                if (comp.shortname.toLowerCase().indexOf(searchText.toLowerCase()) < 0) {\n                    continue;\n                }\n                comp.children = [];\n                comp.haschildren = 0;\n                tree.push(comp);\n            }\n\n            self._competencies = tree;\n\n        }).fail(Notification.exception);\n    };\n\n    /**\n     * Convenience method to get a plan object.\n     *\n     * @param {Number} id The plan ID.\n     * @return {Object|undefined} The plan.\n     * @method _getPlan\n     */\n    Picker.prototype._getPlan = function(id) {\n        var plan;\n        $.each(this._plans, function(i, f) {\n            if (f.id == id) {\n                plan = f;\n                return;\n            }\n        });\n        return plan;\n    };\n\n    /**\n     * Load the competencies.\n     *\n     * @method _loadCompetencies\n     * @return {Promise}\n     */\n    Picker.prototype._loadCompetencies = function() {\n        return this._fetchCompetencies(this._planId, this._searchText);\n    };\n\n    /**\n     * Load the plans.\n     *\n     * @method _loadPlans\n     * @return {Promise}\n     */\n    Picker.prototype._loadPlans = function() {\n        var promise,\n            self = this;\n\n        // Quit early because we already have the data.\n        if (self._plans.length > 0) {\n            return $.when();\n        }\n\n        if (self._singlePlan) {\n            promise = Ajax.call([\n                {methodname: 'core_competency_read_plan', args: {\n                    id: this._planId\n                }}\n            ])[0].then(function(plan) {\n                return [plan];\n            });\n        } else {\n            promise = Ajax.call([\n                {methodname: 'core_competency_list_user_plans', args: {\n                    userid: self._userId\n                }}\n            ])[0];\n        }\n\n        return promise.done(function(plans) {\n            self._plans = plans;\n        }).fail(Notification.exception);\n    };\n\n    /**\n     * Hook to executed before render.\n     *\n     * @method _preRender\n     * @return {Promise}\n     */\n    Picker.prototype._preRender = function() {\n        var self = this;\n        return self._loadPlans().then(function() {\n            if (!self._planId && self._plans.length > 0) {\n                self._planId = self._plans[0].id;\n            }\n\n            // We could not set a framework ID, that probably means there are no frameworks accessible.\n            if (!self._planId) {\n                self._plans = [];\n                return $.when();\n            }\n\n            return self._loadCompetencies();\n        });\n    };\n\n    /**\n     * Render the dialogue.\n     *\n     * @method _render\n     * @return {Promise}\n     */\n    Picker.prototype._render = function() {\n        var self = this;\n        return self._preRender().then(function() {\n\n            if (!self._singlePlan) {\n                $.each(self._plans, function(i, plan) {\n                    if (plan.id == self._planId) {\n                        plan.selected = true;\n                    } else {\n                        plan.selected = false;\n                    }\n                });\n            }\n\n            var context = {\n                competencies: self._competencies,\n                plan: self._getPlan(self._planId),\n                plans: self._plans,\n                search: self._searchText,\n                singlePlan: self._singlePlan,\n            };\n\n            return Templates.render('tool_lp/competency_picker_user_plans', context);\n        });\n    };\n\n    return /** @alias module:tool_lp/competencypicker_user_plans */ Picker;\n\n});\n"],"file":"competencypicker_user_plans.min.js"}