Current Path : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/ |
Current File : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/competencyactions.min.js |
define ("tool_lp/competencyactions",["jquery","core/url","core/templates","core/notification","core/str","core/ajax","tool_lp/dragdrop-reorder","tool_lp/tree","tool_lp/dialogue","tool_lp/menubar","tool_lp/competencypicker","tool_lp/competency_outcomes","tool_lp/competencyruleconfig","core/pending"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=null,p=null,q=null,r,s,t,u,v,w,x=null,y=function(){var c=a("[data-region=\"competencyactions\"]").data("competency"),f={competencyframeworkid:o.getCompetencyFrameworkId(),pagecontextid:r};if(null!==c){f.parentid=c.id}var g=function(){var c=a.param(f);window.location=b.relativeUrl("/admin/tool/lp/editcompetency.php?"+c)};if(null!==c&&o.hasRule(c.id)){e.get_strings([{key:"confirm",component:"moodle"},{key:"addingcompetencywillresetparentrule",component:"tool_lp",param:c.shortname},{key:"yes",component:"core"},{key:"no",component:"core"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],g)}).fail(d.exception)}else{g()}},z=function(){var b=a("[data-region=\"filtercompetencies\"]").data("frameworkid"),c=f.call([{methodname:"core_competency_set_parent_competency",args:{competencyid:p,parentid:q}},{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:b,search:a("[data-region=\"filtercompetencies\"] input").val()}}]);c[1].done(F).fail(d.exception)},A=function(){q="undefined"==typeof q?0:q;if(q==p){return}var a=o.getCompetency(q)||{},b=o.getCompetency(p)||{},c="movecompetencywillresetrules",f=!1;if(b.parentid==q){return}if(a.path&&0<=a.path.indexOf("/"+b.id+"/")){c="movecompetencytochildofselfwillresetrules";f=f||o.hasRule(b.id)}f=f||o.hasRule(a.id)||o.hasRule(b.parentid);if(f){e.get_strings([{key:"confirm",component:"moodle"},{key:c,component:"tool_lp"},{key:"yes",component:"moodle"},{key:"no",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],z)}).fail(d.exception)}else{z()}},B=function(b){var c=a(b.getContent()),d=c.find("[data-enhance=movetree]"),e=new h(d,!1);e.on("selectionchanged",function(b,c){var d=c.selected;q=a(d).data("id")});d.show();c.on("click","[data-action=\"move\"]",function(){b.close();A()});c.on("click","[data-action=\"cancel\"]",function(){b.close()})},C=function(a,b){var c;for(c=0;c<b.length;c++){if(b[c].parentid==a.id){a.haschildren=!0;b[c].children=[];b[c].haschildren=!1;a.children[a.children.length]=b[c];C(b[c],b)}}},D=function(b){b.preventDefault();var g=a("[data-region=\"competencyactions\"]").data("competency");p=g.id;var h=f.call([{methodname:"core_competency_search_competencies",args:{competencyframeworkid:g.competencyframeworkid,searchtext:""}},{methodname:"core_competency_read_competency_framework",args:{id:g.competencyframeworkid}}]);a.when.apply(null,h).done(function(a,b){var f,h=[];for(f=0;f<a.length;f++){var j=a[f];if("0"==j.parentid){j.children=[];j.haschildren=0;h[h.length]=j;C(j,a)}}e.get_strings([{key:"movecompetency",component:"tool_lp",param:g.shortname},{key:"move",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done(function(a){c.render("tool_lp/competencies_move_tree",{framework:b,competencies:h}).done(function(b){new i(a[0],b,B)}).fail(d.exception)}).fail(d.exception)}).fail(d.exception)},E=function(){var c=a("[data-region=\"competencyactions\"]").data("competency"),d={competencyframeworkid:o.getCompetencyFrameworkId(),id:c.id,parentid:c.parentid,pagecontextid:r},e=a.param(d);window.location=b.relativeUrl("/admin/tool/lp/editcompetency.php?"+e)},F=function(b){c.render("tool_lp/manage_competencies_page",b).done(function(b,d){a("[data-region=\"managecompetencies\"]").replaceWith(b);c.runTemplateJS(d)}).fail(d.exception)},G=function(b){b.preventDefault();var c=a("[data-region=\"filtercompetencies\"]").data("frameworkid"),e=f.call([{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:c,search:a("[data-region=\"filtercompetencies\"] input").val()}}]);e[0].done(F).fail(d.exception)},H=function(){var b=a("[data-region=\"competencyactions\"]").data("competency"),c=f.call([{methodname:"core_competency_move_up_competency",args:{id:b.id}},{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:b.competencyframeworkid,search:a("[data-region=\"filtercompetencies\"] input").val()}}]);c[1].done(F).fail(d.exception)},I=function(){var b=a("[data-region=\"competencyactions\"]").data("competency"),c=f.call([{methodname:"core_competency_move_down_competency",args:{id:b.id}},{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:b.competencyframeworkid,search:a("[data-region=\"filtercompetencies\"] input").val()}}]);c[1].done(F).fail(d.exception)},J=function(){var b=a("[data-region=\"competencyactions\"]").data("competency"),g=f.call([{methodname:"tool_lp_list_courses_using_competency",args:{id:b.id}}]);g[0].done(function(a){c.render("tool_lp/linked_courses_summary",{courses:a}).done(function(a){e.get_string("linkedcourses","tool_lp").done(function(b){new i(b,a,B)}).fail(d.exception)}).fail(d.exception)}).fail(d.exception)},K=function(){u=a("[data-region=\"competencyactions\"]").data("competency");if(!s){s=new k(r,u.competencyframeworkid);s.on("save",function(b,e){var g=new n,h=e.competencyIds,i=[];a.each(h,function(a,b){i.push({methodname:"core_competency_add_related_competency",args:{competencyid:b,relatedcompetencyid:u.id}})});i.push({methodname:"tool_lp_data_for_related_competencies_section",args:{competencyid:u.id}});var j=f.call(i);j[i.length-1].then(function(a){return c.render("tool_lp/related_competencies",a)}).then(function(b,d){a("[data-region=\"relatedcompetencies\"]").replaceWith(b);c.runTemplateJS(d);V()}).then(g.resolve).catch(d.exception)})}s.setDisallowedCompetencyIDs([u.id]);s.display()},L=function(b){b.preventDefault();u=a("[data-region=\"competencyactions\"]").data("competency");t.setTargetCompetencyId(u.id);t.display()},M=function(a,b){var c={id:u.id,shortname:u.shortname,idnumber:u.idnumber,description:u.description,descriptionformat:u.descriptionformat,ruletype:b.ruletype,ruleoutcome:b.ruleoutcome,ruleconfig:b.ruleconfig},e=f.call([{methodname:"core_competency_update_competency",args:{competency:c}}]);e[0].then(function(a){if(a){u.ruletype=b.ruletype;u.ruleoutcome=b.ruleoutcome;u.ruleconfig=b.ruleconfig;Y(u)}}).catch(d.exception)},N=function(){var b=a("[data-region=\"competencyactions\"]").data("competency"),c=f.call([{methodname:"core_competency_delete_competency",args:{id:b.id}},{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:b.competencyframeworkid,search:a("[data-region=\"filtercompetencies\"] input").val()}}]);c[0].done(function(a){if(!1===a){e.get_strings([{key:"competencycannotbedeleted",component:"tool_lp",param:b.shortname},{key:"cancel",component:"moodle"}]).done(function(a){d.alert(null,a[0])}).fail(d.exception)}}).fail(d.exception);c[1].done(F).fail(d.exception)},O=function(){var b=a("[data-region=\"competencyactions\"]").data("competency"),c="deletecompetency";if(o.hasRule(b.parentid)){c="deletecompetencyparenthasrule"}e.get_strings([{key:"confirm",component:"moodle"},{key:c,component:"tool_lp",param:b.shortname},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],N)}).fail(d.exception)},P=function(b){b.originalEvent.dataTransfer.setData("text",a(b.target).parent().data("id"))},Q=function(a){a.originalEvent.dataTransfer.dropEffect="move";a.preventDefault()},R=function(b){b.preventDefault();a(this).addClass("currentdragtarget")},S=function(b){b.preventDefault();a(this).removeClass("currentdragtarget")},T=function(b){b.preventDefault();p=b.originalEvent.dataTransfer.getData("text");q=a(b.target).parent().data("id");a(this).removeClass("currentdragtarget");A()},U=function(b){b.preventDefault();var e=this.id.substr(11),g=a("[data-region=\"competencyactions\"]").data("competency"),h=f.call([{methodname:"core_competency_remove_related_competency",args:{relatedcompetencyid:e,competencyid:g.id}},{methodname:"tool_lp_data_for_related_competencies_section",args:{competencyid:g.id}}]);h[1].done(function(b){c.render("tool_lp/related_competencies",b).done(function(b){a("[data-region=\"relatedcompetencies\"]").replaceWith(b);V()}).fail(d.exception)}).fail(d.exception)},V=function(){a("[data-action=\"deleterelation\"]").on("click",U)},W=function(a){if(a.id!==x){x=a.id;f.call([{methodname:"core_competency_competency_viewed",args:{id:a.id}}])}},X=function(a){var b=v[a];if(!b){b="competency"}return b},Y=function(e){var g=a.Deferred().resolve().promise(),h={};h.competency=e;h.showdeleterelatedaction=!0;h.showrelatedcompetencies=!0;h.showrule=!1;h.pluginbaseurl=b.relativeUrl("/admin/tool/lp");if(e.ruleoutcome!=l.NONE){g=l.getString(e.ruleoutcome).then(function(b){var c;a.each(w,function(a,b){if(b.type==e.ruletype){c=b.name}});return[b,c]})}g.then(function(a){if("undefined"!=typeof a){h.showrule=!0;h.rule={outcome:a[0],type:a[1]}}return h}).then(function(a){return c.render("tool_lp/competency_summary",a)}).then(function(b){a("[data-region=\"competencyinfo\"]").html(b);a("[data-action=\"deleterelation\"]").on("click",U);return c.render("tool_lp/loading",{})}).then(function(a,b){c.replaceNodeContents("[data-region=\"relatedcompetencies\"]",a,b);return f.call([{methodname:"tool_lp_data_for_related_competencies_section",args:{competencyid:e.id}}])[0]}).then(function(a){return c.render("tool_lp/related_competencies",a)}).then(function(b,d){a("[data-region=\"relatedcompetencies\"]").replaceWith(b);c.runTemplateJS(d);V()}).catch(d.exception)},Z=function(a){return e.get_string("taxonomy_add_"+X(a),"tool_lp")},$=function(a){return e.get_string("taxonomy_selected_"+X(a),"tool_lp")},_=function(b,c){var e=c.selected,f=a(e).data("id"),g=a("[data-region=\"competencyactions\"] [data-action=\"add\"]"),h=a("[data-region=\"competencyactionsmenu\"]"),i=a("[data-region=\"selected-competency\"]"),k=0,l=1;j.closeAll();if("undefined"==typeof f){a("[data-region=\"competencyinfo\"]").html(e.clone().children().remove().end().text());a("[data-region=\"competencyactions\"]").data("competency",null);h.hide()}else{var m=o.getCompetency(f);k=o.getCompetencyLevel(f);l=k+1;h.show();a("[data-region=\"competencyactions\"]").data("competency",m);Y(m);W(m)}$(k).then(function(a){i.text(a)}).catch(d.exception);Z(l).then(function(a){g.show().find("[data-region=\"term\"]").text(a)}).catch(d.exception);b.preventDefault();return!1},aa=function(a){var b=a.split(",");b.unshift("");delete b[0];return b};return{init:function init(b,c,d,e){o=b;r=c;v=aa(d);w=e;a("[data-region=\"competencyactions\"] [data-action=\"add\"]").on("click",y);j.enhance(".competencyactionsmenu",{'[data-action="edit"]':E,'[data-action="delete"]':O,'[data-action="move"]':D,'[data-action="moveup"]':H,'[data-action="movedown"]':I,'[data-action="linkedcourses"]':J,'[data-action="relatedcompetencies"]':K.bind(this),'[data-action="competencyrules"]':L.bind(this)});a("[data-region=\"competencyactionsmenu\"]").hide();a("[data-region=\"competencyactions\"] [data-action=\"add\"]").hide();a("[data-region=\"filtercompetencies\"]").on("submit",G);var f=a("[data-region=\"managecompetencies\"] [data-enhance=\"tree\"]");f.on("dragstart","li>span",P).on("dragover","li>span",Q).on("dragenter","li>span",R).on("dragleave","li>span",S).on("drop","li>span",T);b.on("selectionchanged",_);t=new m(o,w);t.on("save",M.bind(this))}}}); //# sourceMappingURL=competencyactions.min.js.map