Current Path : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/ |
Current File : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/user_evidence_actions.min.js |
define ("tool_lp/user_evidence_actions",["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/competencypicker_user_plans"],function(a,b,c,d,e,f,g){var h=function(a){this._type=a;if("evidence"===a){this._region="[data-region=\"user-evidence-page\"]";this._evidenceNode="[data-region=\"user-evidence-page\"]";this._template="tool_lp/user_evidence_page";this._contextMethod="tool_lp_data_for_user_evidence_page"}else if("list"===a){this._region="[data-region=\"user-evidence-list\"]";this._evidenceNode="[data-region=\"user-evidence-node\"]";this._template="tool_lp/user_evidence_list_page";this._contextMethod="tool_lp_data_for_user_evidence_list_page"}else{throw new TypeError("Unexpected type.")}};h.prototype._contextMethod=null;h.prototype._evidenceNode=null;h.prototype._region=null;h.prototype._template=null;h.prototype._type=null;h.prototype._getContextArgs=function(a){var b=this,c={};if("evidence"===b._type){c={id:a.id}}else if("list"===b._type){c={userid:a.userid}}return c};h.prototype._renderView=function(c){var d=this;return b.render(d._template,c).then(function(c,e){b.replaceNode(a(d._region),c,e)})};h.prototype._callAndRefresh=function(b,e){var f=this;b.push({methodname:f._contextMethod,args:f._getContextArgs(e)});return a.when.apply(a.when,c.call(b)).then(function(){return f._renderView(arguments[arguments.length-1])}).fail(d.exception)};h.prototype._doDelete=function(a){var b=this,c=[{methodname:"core_competency_delete_user_evidence",args:{id:a.id}}];b._callAndRefresh(c,a)};h.prototype.deleteEvidence=function(a){var b=this,f;f=c.call([{methodname:"core_competency_read_user_evidence",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"deleteuserevidence",component:"tool_lp",param:c.name},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doDelete(a)})}).fail(d.exception)}).fail(d.exception)};h.prototype._deleteEvidenceHandler=function(b){b.preventDefault();var c=this._findEvidenceData(a(b.target));this.deleteEvidence(c)};h.prototype._doCreateUserEvidenceCompetency=function(b,c){var d=this,e=[];a.each(c,function(a,c){e.push({methodname:"core_competency_create_user_evidence_competency",args:{userevidenceid:b.id,competencyid:c}})});d._callAndRefresh(e,b)};h.prototype.createUserEvidenceCompetency=function(a){var b=this,c=new g(a.userid);c.on("save",function(c,d){var e=d.competencyIds;b._doCreateUserEvidenceCompetency(a,e,d.requestReview)});c.display()};h.prototype._createUserEvidenceCompetencyHandler=function(b){b.preventDefault();var c=this._findEvidenceData(a(b.target));this.createUserEvidenceCompetency(c)};h.prototype._doDeleteUserEvidenceCompetency=function(a,b){var c=this,d=[];d.push({methodname:"core_competency_delete_user_evidence_competency",args:{userevidenceid:a.id,competencyid:b}});c._callAndRefresh(d,a)};h.prototype.deleteUserEvidenceCompetency=function(a,b){this._doDeleteUserEvidenceCompetency(a,b)};h.prototype._deleteUserEvidenceCompetencyHandler=function(b){var c=this._findEvidenceData(a(b.currentTarget)),d=a(b.currentTarget).data("id");b.preventDefault();this.deleteUserEvidenceCompetency(c,d)};h.prototype._doReviewUserEvidenceCompetencies=function(a){var b=this,c=[{methodname:"core_competency_request_review_of_user_evidence_linked_competencies",args:{id:a.id}}];b._callAndRefresh(c,a)};h.prototype.reviewUserEvidenceCompetencies=function(a){var b=this,f;f=c.call([{methodname:"core_competency_read_user_evidence",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"sendallcompetenciestoreview",component:"tool_lp",param:c.name},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doReviewUserEvidenceCompetencies(a)})}).fail(d.exception)}).fail(d.exception)};h.prototype._reviewUserEvidenceCompetenciesHandler=function(b){b.preventDefault();var c=this._findEvidenceData(a(b.target));this.reviewUserEvidenceCompetencies(c)};h.prototype._findEvidenceData=function(b){var c=b.parentsUntil(a(this._region).parent(),this._evidenceNode),d;if(1!=c.length){throw new Error("The evidence node was not located.")}d=c.data();if("undefined"==typeof d||"undefined"==typeof d.id){throw new Error("Evidence data could not be found.")}return d};h.prototype.enhanceMenubar=function(a){var b=this;f.enhance(a,{'[data-action="user-evidence-delete"]':b._deleteEvidenceHandler.bind(b),'[data-action="link-competency"]':b._createUserEvidenceCompetencyHandler.bind(b),'[data-action="send-competencies-review"]':b._reviewUserEvidenceCompetenciesHandler.bind(b)})};h.prototype.registerEvents=function(){var b=a(this._region),c=this;b.find("[data-action=\"user-evidence-delete\"]").click(c._deleteEvidenceHandler.bind(c));b.find("[data-action=\"link-competency\"]").click(c._createUserEvidenceCompetencyHandler.bind(c));b.find("[data-action=\"delete-competency-link\"]").click(c._deleteUserEvidenceCompetencyHandler.bind(c));b.find("[data-action=\"send-competencies-review\"]").click(c._reviewUserEvidenceCompetenciesHandler.bind(c))};return h}); //# sourceMappingURL=user_evidence_actions.min.js.map