Current Path : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/ |
Current File : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/competencytree.min.js |
define ("tool_lp/competencytree",["core/ajax","core/notification","core/templates","tool_lp/tree","tool_lp/competency_outcomes","jquery"],function(a,b,c,d,e,f){var g={},h=0,j="",k="",l="",m=!1,n=function(a,b){var c=0,d=!1;a.haschildren=!1;a.children=[];for(c=0;c<b.length;c++){d=b[c];if(d.parentid==a.id){a.haschildren=!0;a.children.push(d);n(d,b)}}},o=function(b){var e=f.Deferred();c.render("tool_lp/loading",{}).done(function(i,o){c.replaceNodeContents(f(k),i,o);var p=a.call([{methodname:"core_competency_search_competencies",args:{searchtext:b,competencyframeworkid:h}}]);p[0].done(function(a){g={};var b=0;for(b=0;b<a.length;b++){g[a[b].id]=a[b]}var h=[],o=!1;for(b=0;b<a.length;b++){o=a[b];if(0===parseInt(o.parentid,10)){h.push(o);n(o,a)}}var p={shortname:j,canmanage:m,competencies:h};c.render("tool_lp/competencies_tree_root",p).done(function(a,b){c.replaceNodeContents(f(k),f(a).html(),b);var h=new d(k,!1);if(l){var i=f(k).find("[data-id="+l+"]");if(i.length){h.selectItem(i);h.updateFocus(i)}}e.resolve(g)}).fail(e.reject)}).fail(e.reject)});return e.promise()},p=function(a,b){var c=b.selected;l=c.attr("data-id")};return{init:function init(a,c,d,e,f,g){h=a;j=c;m=f;k=e;o(d).fail(b.exception);if(0<g){l=g}this.on("selectionchanged",p)},on:function on(a,b){f(k).on(a,b)},getChildren:function getChildren(a){var b=[];f.each(g,function(c,d){if(d.parentid==a){b.push(d)}});return b},getCompetencyFrameworkId:function getCompetencyFrameworkId(){return h},getCompetency:function getCompetency(a){return g[a]},getCompetencyLevel:function getCompetencyLevel(a){var b=this.getCompetency(a),c=b.path.replace(/^\/|\/$/g,"").split("/").length;return c},hasChildren:function hasChildren(a){return 0<this.getChildren(a).length},hasRule:function hasRule(a){var b=this.getCompetency(a);if(b){return b.ruleoutcome!=e.OUTCOME_NONE&&b.ruletype}return!1},reloadCompetencies:function reloadCompetencies(){return o("").fail(b.exception)},listCompetencies:function listCompetencies(){return g}}}); //# sourceMappingURL=competencytree.min.js.map