芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/public_html/cepali/admin/tool/lp/amd/build/competencies.min.js
define(["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/competencypicker","tool_lp/dragdrop-reorder","core/pending"],function(a,b,c,d,e,f,g,h){var i=function(b,c,d){this.itemid=b,this.itemtype=c,this.pageContextId=d,this.pickerInstance=null,a('[data-region="actions"] button').prop("disabled",!1),this.registerEvents(),this.registerDragDrop()};return i.prototype.registerDragDrop=function(){var a=this;e.get_string("movecompetency","tool_lp").done(function(b){g.dragdrop("movecompetency",b,{identifier:"movecompetency",component:"tool_lp"},{identifier:"movecompetencyafter",component:"tool_lp"},"drag-samenode","drag-parentnode","drag-handlecontainer",function(b,c){a.handleDrop(b,c)})}).fail(b.exception)},i.prototype.handleDrop=function(d,e){var f=a(d).data("id"),g=a(e).data("id"),h=this,i=[];if("course"==h.itemtype)i=c.call([{methodname:"core_competency_reorder_course_competency",args:{courseid:h.itemid,competencyidfrom:f,competencyidto:g}}]);else if("template"==h.itemtype)i=c.call([{methodname:"core_competency_reorder_template_competency",args:{templateid:h.itemid,competencyidfrom:f,competencyidto:g}}]);else{if("plan"!=h.itemtype)return;i=c.call([{methodname:"core_competency_reorder_plan_competency",args:{planid:h.itemid,competencyidfrom:f,competencyidto:g}}])}i[0].fail(b.exception)},i.prototype.pickCompetency=function(){var e,g,i,j,k=this;return k.pickerInstance||("template"!==k.itemtype&&"course"!==k.itemtype||(j="parents"),k.pickerInstance=new f(k.pageContextId,(!1),j),k.pickerInstance.on("save",function(f,j){var l=j.competencyIds,m=new h;"course"===k.itemtype?(e=[],a.each(l,function(a,b){e.push({methodname:"core_competency_add_competency_to_course",args:{courseid:k.itemid,competencyid:b}})}),e.push({methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:k.itemid,moduleid:0}}),g="tool_lp/course_competencies_page",i="coursecompetenciespage"):"template"===k.itemtype?(e=[],a.each(l,function(a,b){e.push({methodname:"core_competency_add_competency_to_template",args:{templateid:k.itemid,competencyid:b}})}),e.push({methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:k.itemid,pagecontext:{contextid:k.pageContextId}}}),g="tool_lp/template_competencies_page",i="templatecompetenciespage"):"plan"===k.itemtype&&(e=[],a.each(l,function(a,b){e.push({methodname:"core_competency_add_competency_to_plan",args:{planid:k.itemid,competencyid:b}})}),e.push({methodname:"tool_lp_data_for_plan_page",args:{planid:k.itemid}}),g="tool_lp/plan_page",i="plan-page"),c.call(e)[e.length-1].then(function(a){return d.render(g,a)}).then(function(b,c){d.replaceNode(a('[data-region="'+i+'"]'),b,c)}).then(m.resolve)["catch"](b.exception)})),k.pickerInstance.display()},i.prototype.doDelete=function(e){var f=this,g=[],h="",i="";"course"==f.itemtype?(g=c.call([{methodname:"core_competency_remove_competency_from_course",args:{courseid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:f.itemid,moduleid:0}}]),h="tool_lp/course_competencies_page",i="coursecompetenciespage"):"template"==f.itemtype?(g=c.call([{methodname:"core_competency_remove_competency_from_template",args:{templateid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:f.itemid,pagecontext:{contextid:f.pageContextId}}}]),h="tool_lp/template_competencies_page",i="templatecompetenciespage"):"plan"==f.itemtype&&(g=c.call([{methodname:"core_competency_remove_competency_from_plan",args:{planid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_plan_page",args:{planid:f.itemid}}]),h="tool_lp/plan_page",i="plan-page"),g[1].done(function(c){d.render(h,c).done(function(b,c){a('[data-region="'+i+'"]').replaceWith(b),d.runTemplateJS(c)}).fail(b.exception)}).fail(b.exception)},i.prototype.deleteHandler=function(a){var d,f=this,g=[];if("course"==f.itemtype)d="unlinkcompetencycourse";else if("template"==f.itemtype)d="unlinkcompetencytemplate";else{if("plan"!=f.itemtype)return;d="unlinkcompetencyplan"}g=c.call([{methodname:"core_competency_read_competency",args:{id:a}}]),g[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:d,component:"tool_lp",param:c.shortname},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){b.confirm(c[0],c[1],c[2],c[3],function(){f.doDelete(a)})}).fail(b.exception)}).fail(b.exception)},i.prototype.registerEvents=function(){var e=this;"course"==e.itemtype&&a('[data-region="coursecompetenciespage"]').on("change",'select[data-field="ruleoutcome"]',function(f){var g=new h,i=[],j="tool_lp/course_competencies_page",k="coursecompetenciespage",l=a(f.target).data("id"),m=a(f.target).val();i=c.call([{methodname:"core_competency_set_course_competency_ruleoutcome",args:{coursecompetencyid:l,ruleoutcome:m}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:e.itemid,moduleid:0}}]),i[1].then(function(a){return d.render(j,a)}).then(function(b,c){return d.replaceNode(a('[data-region="'+k+'"]'),b,c)}).then(g.resolve)["catch"](b.exception)}),a('[data-region="actions"] button').click(function(a){var b=new h;a.preventDefault(),e.pickCompetency().then(b.resolve)["catch"]()}),a('[data-action="delete-competency-link"]').click(function(b){b.preventDefault();var c=a(b.target).closest("[data-id]").data("id");e.deleteHandler(c)})},i});