You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
7.6 KiB

define(["jquery","core/templates","core/ajax","core/notification","core/str","tool_lp/menubar","tool_lp/dialogue"],function(a,b,c,d,e,f,g){var h=function(a){if(this._type=a,"plan"===a)this._region='[data-region="plan-page"]',this._planNode='[data-region="plan-page"]',this._template="tool_lp/plan_page",this._contextMethod="tool_lp_data_for_plan_page";else{if("plans"!==a)throw new TypeError("Unexpected type.");this._region='[data-region="plans"]',this._planNode='[data-region="plan-node"]',this._template="tool_lp/plans_page",this._contextMethod="tool_lp_data_for_plans_page"}};return h.prototype._contextMethod=null,h.prototype._planNode=null,h.prototype._region=null,h.prototype._template=null,h.prototype._type=null,h.prototype._getContextArgs=function(a){var b=this,c={};return"plan"===b._type?c={planid:a.id}:"plans"===b._type&&(c={userid:a.userid}),c},h.prototype.refresh=function(b){var c=this._findPlanData(a(b));this._callAndRefresh([],c)},h.prototype._renderView=function(c){var d=this;return b.render(d._template,c).then(function(c,e){a(d._region).replaceWith(c),b.runTemplateJS(e)})},h.prototype._callAndRefresh=function(b,e){var f="tool_lp/planactions:_callAndRefresh-"+Math.floor(Math.random()*Math.floor(1e3));M.util.js_pending(f);var g=this;return b.push({methodname:g._contextMethod,args:g._getContextArgs(e)}),a.when.apply(a,c.call(b)).then(function(){return g._renderView(arguments[arguments.length-1])}).fail(d.exception).always(function(){return M.util.js_complete(f)})},h.prototype._doDelete=function(a){var b=this,c=[{methodname:"core_competency_delete_plan",args:{id:a.id}}];b._callAndRefresh(c,a)},h.prototype.deletePlan=function(a){var b,f=this;b=c.call([{methodname:"core_competency_read_plan",args:{id:a.id}}]),b[0].done(function(b){e.get_strings([{key:"confirm",component:"moodle"},{key:"deleteplan",component:"tool_lp",param:b.name},{key:"delete",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(b){d.confirm(b[0],b[1],b[2],b[3],function(){f._doDelete(a)})}).fail(d.exception)}).fail(d.exception)},h.prototype._doReopenPlan=function(a){var b=this,c=[{methodname:"core_competency_reopen_plan",args:{planid:a.id}}];b._callAndRefresh(c,a)},h.prototype.reopenPlan=function(a){var b=this,f=c.call([{methodname:"core_competency_read_plan",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"reopenplanconfirm",component:"tool_lp",param:c.name},{key:"reopenplan",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doReopenPlan(a)})}).fail(d.exception)}).fail(d.exception)},h.prototype._doCompletePlan=function(a){var b=this,c=[{methodname:"core_competency_complete_plan",args:{planid:a.id}}];b._callAndRefresh(c,a)},h.prototype.completePlan=function(a){var b=this,f=c.call([{methodname:"core_competency_read_plan",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"completeplanconfirm",component:"tool_lp",param:c.name},{key:"completeplan",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doCompletePlan(a)})}).fail(d.exception)}).fail(d.exception)},h.prototype._doUnlinkPlan=function(a){var b=this,c=[{methodname:"core_competency_unlink_plan_from_template",args:{planid:a.id}}];b._callAndRefresh(c,a)},h.prototype.unlinkPlan=function(a){var b=this,f=c.call([{methodname:"core_competency_read_plan",args:{id:a.id}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:"unlinkplantemplateconfirm",component:"tool_lp",param:c.name},{key:"unlinkplantemplate",component:"tool_lp"},{key:"cancel",component:"moodle"}]).done(function(c){d.confirm(c[0],c[1],c[2],c[3],function(){b._doUnlinkPlan(a)})}).fail(d.exception)}).fail(d.exception)},h.prototype._doRequestReview=function(a){var b=[{methodname:"core_competency_plan_request_review",args:{id:a.id}}];this._callAndRefresh(b,a)},h.prototype.requestReview=function(a){this._doRequestReview(a)},h.prototype._doCancelReviewRequest=function(a){var b=[{meth