Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"user_competency_plan_popup.min.js","sources":["../src/user_competency_plan_popup.js"],"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 * Module to open user competency plan in popup\n *\n * @module     tool_lp/user_competency_plan_popup\n * @copyright  2016 Issam Taboubi <issam.taboubi@umontreal.ca>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates', 'tool_lp/dialogue'],\n       function($, notification, str, ajax, templates, Dialogue) {\n\n    /**\n     * UserCompetencyPopup\n     *\n     * @param {String} regionSelector The regionSelector\n     * @param {String} userCompetencySelector The userCompetencySelector\n     * @param {Number} planId The plan ID\n     */\n    var UserCompetencyPopup = function(regionSelector, userCompetencySelector, planId) {\n        this._regionSelector = regionSelector;\n        this._userCompetencySelector = userCompetencySelector;\n        this._planId = planId;\n\n        $(this._regionSelector).on('click', this._userCompetencySelector, this._handleClick.bind(this));\n    };\n\n    /**\n     * Get the data from the closest TR and open the popup.\n     *\n     * @method _handleClick\n     * @param {Event} e\n     */\n    UserCompetencyPopup.prototype._handleClick = function(e) {\n        e.preventDefault();\n        var tr = $(e.target).closest('tr');\n        var competencyId = $(tr).data('competencyid');\n        var userId = $(tr).data('userid');\n        var planId = this._planId;\n\n        var requests = ajax.call([{\n            methodname: 'tool_lp_data_for_user_competency_summary_in_plan',\n            args: {competencyid: competencyId, planid: planId},\n            done: this._contextLoaded.bind(this),\n            fail: notification.exception\n        }]);\n        // Log the user competency viewed in plan event.\n        requests[0].then(function(result) {\n            var eventMethodName = 'core_competency_user_competency_viewed_in_plan';\n            // Trigger core_competency_user_competency_plan_viewed event instead if plan is already completed.\n            if (result.plan.iscompleted) {\n                eventMethodName = 'core_competency_user_competency_plan_viewed';\n            }\n            return ajax.call([{\n                methodname: eventMethodName,\n                args: {competencyid: competencyId, userid: userId, planid: planId}\n            }])[0];\n        }).catch(notification.exception);\n    };\n\n    /**\n     * We loaded the context, now render the template.\n     *\n     * @method _contextLoaded\n     * @param {Object} context\n     */\n    UserCompetencyPopup.prototype._contextLoaded = function(context) {\n        var self = this;\n        templates.render('tool_lp/user_competency_summary_in_plan', context).done(function(html, js) {\n            str.get_string('usercompetencysummary', 'report_competency').done(function(title) {\n                (new Dialogue(title, html, templates.runTemplateJS.bind(templates, js), self._refresh.bind(self), true));\n            }).fail(notification.exception);\n        }).fail(notification.exception);\n    };\n\n    /**\n     * Refresh the page.\n     *\n     * @method _refresh\n     */\n    UserCompetencyPopup.prototype._refresh = function() {\n        var planId = this._planId;\n\n        ajax.call([{\n            methodname: 'tool_lp_data_for_plan_page',\n            args: {planid: planId},\n            done: this._pageContextLoaded.bind(this),\n            fail: notification.exception\n        }]);\n    };\n\n    /**\n     * We loaded the context, now render the template.\n     *\n     * @method _pageContextLoaded\n     * @param {Object} context\n     */\n    UserCompetencyPopup.prototype._pageContextLoaded = function(context) {\n        var self = this;\n        templates.render('tool_lp/plan_page', context).done(function(html, js) {\n            templates.replaceNode(self._regionSelector, html, js);\n        }).fail(notification.exception);\n    };\n\n    /** @property {String} The selector for the region with the user competencies */\n    UserCompetencyPopup.prototype._regionSelector = null;\n    /** @property {String} The selector for the region with a single user competencies */\n    UserCompetencyPopup.prototype._userCompetencySelector = null;\n    /** @property {Number} The plan Id */\n    UserCompetencyPopup.prototype._planId = null;\n\n    return /** @alias module:tool_lp/user_competency_plan_popup */ UserCompetencyPopup;\n\n});\n"],"names":["define","$","notification","str","ajax","templates","Dialogue","UserCompetencyPopup","regionSelector","userCompetencySelector","planId","_regionSelector","_userCompetencySelector","_planId","this","on","_handleClick","bind","prototype","e","preventDefault","tr","target","closest","competencyId","data","userId","call","methodname","args","competencyid","planid","done","_contextLoaded","fail","exception","then","result","eventMethodName","plan","iscompleted","userid","catch","context","self","render","html","js","get_string","title","runTemplateJS","_refresh","_pageContextLoaded","replaceNode"],"mappings":";;;;;;;AAuBAA,4CAAO,CAAC,SAAU,oBAAqB,WAAY,YAAa,iBAAkB,qBAC3E,SAASC,EAAGC,aAAcC,IAAKC,KAAMC,UAAWC,cAS/CC,oBAAsB,SAASC,eAAgBC,uBAAwBC,aAClEC,gBAAkBH,oBAClBI,wBAA0BH,4BAC1BI,QAAUH,OAEfT,EAAEa,KAAKH,iBAAiBI,GAAG,QAASD,KAAKF,wBAAyBE,KAAKE,aAAaC,KAAKH,eAS7FP,oBAAoBW,UAAUF,aAAe,SAASG,GAClDA,EAAEC,qBACEC,GAAKpB,EAAEkB,EAAEG,QAAQC,QAAQ,MACzBC,aAAevB,EAAEoB,IAAII,KAAK,gBAC1BC,OAASzB,EAAEoB,IAAII,KAAK,UACpBf,OAASI,KAAKD,QAEHT,KAAKuB,KAAK,CAAC,CACtBC,WAAY,mDACZC,KAAM,CAACC,aAAcN,aAAcO,OAAQrB,QAC3CsB,KAAMlB,KAAKmB,eAAehB,KAAKH,MAC/BoB,KAAMhC,aAAaiC,aAGd,GAAGC,MAAK,SAASC,YAClBC,gBAAkB,wDAElBD,OAAOE,KAAKC,cACZF,gBAAkB,+CAEflC,KAAKuB,KAAK,CAAC,CACdC,WAAYU,gBACZT,KAAM,CAACC,aAAcN,aAAciB,OAAQf,OAAQK,OAAQrB,WAC3D,MACLgC,MAAMxC,aAAaiC,YAS1B5B,oBAAoBW,UAAUe,eAAiB,SAASU,aAChDC,KAAO9B,KACXT,UAAUwC,OAAO,0CAA2CF,SAASX,MAAK,SAASc,KAAMC,IACr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