define("local_treestudyplan/studyplan-editor-components",["exports","./simpleline/simpleline","core/ajax","core/notification","core/str","./util/string-helper","./studyplan-processor","./util/debugger","./downloader","./treestudyplan-components"],(function(_exports,_simpleline,_ajax,_notification,_str,_stringHelper,_studyplanProcessor,_debugger,_downloader,_treestudyplanComponents){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _createForOfIteratorHelper(o,allowArrayLike){var it="undefined"!=typeof Symbol&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(o))||allowArrayLike&&o&&"number"==typeof o.length){it&&(o=it);var i=0,F=function(){};return{s:F,n:function(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var err,normalCompletion=!0,didErr=!1;return{s:function(){it=it.call(o)},n:function(){var step=it.next();return normalCompletion=step.done,step},e:function(_e2){didErr=!0,err=_e2},f:function(){try{normalCompletion||null==it.return||it.return()}finally{if(didErr)throw err}}}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i\n {{text.advanced_tools}}\n \n \n \n \n {{ text.advanced_warning}}\n \n \n \n \n

{{ text.advanced_cascade_cohortsync_title}}

\n {{ text.advanced_cascade_cohortsync_desc}}\n
\n \n {{ text.advanced_cascade_cohortsync}}\n \n \n

{{ text.advanced_force_scale_title}}

\n {{ text.advanced_force_scale_desc}}\n
\n \n \n \n \n \n {{ text.advanced_force_scale_button}}\n \n\n \n \n
    \n
  • \n {{c.course.fullname}}\n
      \n
    • \n {{g.name}}\n {{text.advanced_converted}}{{text.advanced_skipped}}\n {{text.advanced_error}}\n
    • \n
    \n
  • \n
\n
\n \n

{{ text.advanced_disable_autoenddate_title}}

\n {{ text.advanced_disable_autoenddate_desc}}\n
\n \n {{ text.advanced_disable_autoenddate_button}}\n \n
\n
\n \n {{ text.advanced_export}}\n {{ text.advanced_import}}\n {{ text.advanced_export_csv}}\n \n \n

{{text.advanced_purge_expl}}

\n

{{ text.advanced_purge}}

\n
\n
\n
\n \n '}),Vue.component("t-studyplan-edit",{props:{value:{type:Object,default:function(){return null}},mode:{type:String,default:function(){return"edit"}},type:{type:String,default:function(){return"link"}},variant:{type:String,default:function(){return""}},contextid:{type:Number,default:1}},data:function(){return{show:!1,config:{userfields:[{key:"selected"},{key:"firstname",sortable:!0},{key:"lastname",sortable:!0}],cohortfields:[{key:"selected"},{key:"name",sortable:!0},{key:"context",sortable:!0}]},editdata:{name:"",shortname:"",description:"",idnumber:"",context_id:this.contextid,periods:4,startdate:(new Date).getFullYear()+"-08-01",enddate:(new Date).getFullYear()+1+"-08-01",aggregation:"bistate",aggregation_config:""},aggregation_parsed:{},aggregators:[],categories:[{context_id:1,category:{path:"System"}}],text:strings.studyplan_edit}},created:function(){var self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_list_aggregators",args:[]}])[0].done((function(response){for(var ix in self.aggregators=response,self.aggregators){var ag=self.aggregators[ix];try{ag.defaultconfig&&ag.defaultconfig.length>0&&(self.aggregation_parsed[ag.id]=JSON.parse(ag.defaultconfig))}catch(e){debug.warn(e)}}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_accessible_categories",args:{operation:"edit"}}])[0].done((function(response){for(var ix in response){var cat=response[ix];cat.category.pathname=cat.category.path.join(" / ")}self.categories=response})).fail(_notification.default.exception)},mounted:function(){},updated:function(){},computed:{},methods:{editPlanStart:function(){if("create"!=this.mode&&((0,_studyplanProcessor.objCopy)(this.editdata,this.value.pages[0],STUDYPLAN_EDITOR_PAGE_FIELDS),(0,_studyplanProcessor.objCopy)(this.editdata,this.value,STUDYPLAN_EDITOR_FIELDS)),this.editdata.aggregation_config&&this.editdata.aggregation_config.length>0)try{this.aggregation_parsed[this.editdata.aggregation]=JSON.parse(this.editdata.aggregation_config)}catch(e){debug.warn(e)}this.show=!0},editPlanFinish:function(){var self=this,args={},method="local_treestudyplan_edit_studyplan";"create"==this.mode?method="local_treestudyplan_add_studyplan":args.id=this.value.id,this.aggregation_parsed[this.editdata.aggregation]&&(this.editdata.aggregation_config=JSON.stringify(this.aggregation_parsed[this.editdata.aggregation])),(0,_studyplanProcessor.objCopy)(args,this.editdata,STUDYPLAN_EDITOR_FIELDS),(0,_studyplanProcessor.objCopy)(args,this.editdata,STUDYPLAN_EDITOR_PAGE_FIELDS),(0,_ajax.call)([{methodname:method,args:args}])[0].done((function(response){if("create"==self.mode)self.$emit("created",response),self.editdata={name:"",shortname:"",description:"",context_id:1,periods:4,startdate:(new Date).getFullYear()+"-08-01",enddate:(new Date).getFullYear()+1+"-08-01",aggregation:"bistate",aggregation_config:""};else{var moved_from=self.value.context_id,moved_to=response.context_id,moved=moved_from!=moved_to;response.pages[0].periods!=self.value.pages[0].periods?(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:self.value.id}}])[0].done((function(response){self.value=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),debug.info("studyplan processed"),self.$emit("input",self.value)})).fail((function(error){_notification.default.exception(error)})):((0,_studyplanProcessor.objCopy)(self.value,response,STUDYPLAN_EDITOR_FIELDS),self.$emit("input",self.value),moved&&self.$emit("moved",self.value,moved_from,moved_to))}})).fail(_notification.default.exception)},numberFilter:function(value){return value}},template:'\n \n \n \n \n \n \n {{ text.studyplan_name}}\n \n 0\'\n :placeholder="text.studyplan_name_ph">\n \n \n \n {{ text.studyplan_shortname}}\n \n 0\'\n :placeholder="text.studyplan_shortname_ph">\n \n \n \n {{ text.studyplan_idnumber}}\n \n \n \n \n {{ text.studyplan_description}}\n \n \n \n \n \n {{ text.studyplan_context}}\n \n \n \n \n \n {{ text.studyplan_slots}}\n \n \n \n \n \n {{ text.studyplan_startdate}}\n \n \n \n \n \n {{ text.studyplan_enddate}}\n \n \n \n \n \n {{ text.choose_aggregation_style}}\n \n \n \n \n \n \n \n \n '}),Vue.component("t-studyplan-associate",{props:["value"],data:function(){return{show:!1,config:{userfields:[{key:"selected"},{key:"firstname",sortable:!0},{key:"lastname",sortable:!0}],cohortfields:[{key:"selected"},{key:"name",sortable:!0},{key:"context",sortable:!0}]},association:{cohorts:[],users:[]},loading:{cohorts:!1,users:!1},search:{users:[],cohorts:[]},selected:{search:{users:[],cohorts:[]},associated:{users:[],cohorts:[]}},text:strings.studyplan_associate}},created:function(){},mounted:function(){},updated:function(){},methods:{showModal:function(){this.show=!0,this.loadAssociations()},cohortOptionModel:function(c){return{val:c.id,text:c.name+" ("+c.context.path.join(" / ")+")"}},userOptionModel:function(u){return{value:u.id,text:u.firstname+" "+u.lastname}},loadAssociations:function(){var self=this;self.loading.cohorts=!0,self.loading.users=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_associated_users",args:{studyplan_id:self.value.id}}])[0].done((function(response){self.association.users=response.map(self.userOptionModel),self.loading.users=!1})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_associated_cohorts",args:{studyplan_id:self.value.id}}])[0].done((function(response){self.association.cohorts=response.map(self.cohortOptionModel),self.loading.cohorts=!1})).fail(_notification.default.exception)},searchCohorts:function(searchtext){var self=this;searchtext.length>0?(0,_ajax.call)([{methodname:"local_treestudyplan_list_cohort",args:{like:searchtext,exclude_id:self.value.id}}])[0].done((function(response){self.search.cohorts=response.map(self.cohortOptionModel)})).fail(_notification.default.exception):self.search.cohorts=[]},cohortAssociate:function(){var self=this,requests=[],associated=self.association.cohorts,search=self.search.cohorts,searchselected=self.selected.search.cohorts,_loop=function(i){var r=searchselected[i];requests.push({methodname:"local_treestudyplan_connect_cohort",args:{studyplan_id:self.value.id,cohort_id:r},fail:_notification.default.exception,done:function(response){response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)}})};for(var i in searchselected)_loop(i);(0,_ajax.call)(requests)},cohortDisassociate:function(){var self=this,requests=[],associatedselected=self.selected.associated.cohorts,associated=self.association.cohorts,search=self.search.cohorts,_loop2=function(i){var r=associatedselected[i];requests.push({methodname:"local_treestudyplan_disconnect_cohort",args:{studyplan_id:self.value.id,cohort_id:r},fail:_notification.default.exception,done:function(response){response.success&&(0,_studyplanProcessor.transportItem)(search,associated,r)}})};for(var i in associatedselected)_loop2(i);(0,_ajax.call)(requests)},searchUsers:function(searchtext){var self=this;searchtext.length>0?(0,_ajax.call)([{methodname:"local_treestudyplan_find_user",args:{like:searchtext,exclude_id:self.value.id}}])[0].done((function(response){self.search.users=response.map(self.userOptionModel)})).fail(_notification.default.exception):self.search.users=[]},userAssociate:function(){var self=this,requests=[],associated=self.association.users,search=self.search.users,searchselected=self.selected.search.users,_loop3=function(i){var r=searchselected[i];requests.push({methodname:"local_treestudyplan_connect_user",args:{studyplan_id:self.value.id,user_id:r},fail:_notification.default.exception,done:function(response){response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)}})};for(var i in searchselected)_loop3(i);(0,_ajax.call)(requests)},userDisassociate:function(){var self=this,requests=[],associated=self.association.users,associatedselected=self.selected.associated.users,search=self.search.users,_loop4=function(i){var r=associatedselected[i];requests.push({methodname:"local_treestudyplan_disconnect_user",args:{studyplan_id:self.value.id,user_id:r},fail:_notification.default.exception,done:function(response){response.success&&(0,_studyplanProcessor.transportItem)(search,associated,r)}})};for(var i in associatedselected)_loop4(i);(0,_ajax.call)(requests)}},template:'\n\n \n \n \n \n \n {{text.associated_cohorts}}\n {{text.associate_cohorts}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n  {{text.delete_association}}\n \n \n  {{text.add_association}} \n \n \n \n \n \n \n \n {{text.associated_users}}\n {{text.associate_users}}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n  {{text.delete_association}}\n \n \n  {{text.add_association}} \n \n \n \n \n \n \n \n'}),Vue.component("t-period-edit",{props:{value:{type:Object,default:function(){return null}},type:{type:String,default:function(){return"link"}},variant:{type:String,default:function(){return""}}},data:function(){return{show:!1,editdata:{fullname:"",shortname:"",startdate:(new Date).getFullYear()+"-08-01",enddate:(new Date).getFullYear()+1+"-08-01"},text:strings.period_edit}},created:function(){},mounted:function(){},updated:function(){},computed:{},methods:{editStart:function(){(0,_studyplanProcessor.objCopy)(this.editdata,this.value,PERIOD_EDITOR_FIELDS),this.show=!0},editFinish:function(){var self=this,args={id:this.value.id};(0,_studyplanProcessor.objCopy)(args,this.editdata,PERIOD_EDITOR_FIELDS),(0,_ajax.call)([{methodname:"local_treestudyplan_edit_period",args:args}])[0].done((function(response){(0,_studyplanProcessor.objCopy)(self.value,response,PERIOD_EDITOR_FIELDS),self.$emit("input",self.value)})).fail(_notification.default.exception)}},template:'\n \n \n \n \n \n \n {{ text.fullname}}\n \n 0\'\n >\n \n \n \n {{ text.shortname}}\n \n 0\'\n >\n \n \n \n {{ text.studyplan_startdate}}\n \n \n \n \n \n {{ text.studyplan_enddate}}\n \n \n \n \n \n \n \n '}),Vue.component("t-studyplan",{props:["value","index"],data:function(){return{config:{userfields:[{key:"selected"},{key:"firstname",sortable:!0},{key:"lastname",sortable:!0}],cohortfields:[{key:"selected"},{key:"name",sortable:!0},{key:"context",sortable:!0}]},create:{studyline:{name:"",shortname:"",color:"#DDDDDD"}},edit:{studyline:{editmode:!1,data:{name:"",shortname:"",color:"#DDDDDD"},original:{}},studyplan:{data:{name:"",shortname:"",description:"",slots:4,startdate:"2020-08-01",enddate:"",aggregation:"",aggregation_config:"",aggregation_info:{useRequiredGrades:!0,useItemCondition:!1}},original:{}}},text:strings.studyplan_text,cache:{linelayers:{}}}},created:function(){},mounted:function(){0==this.page.studylines.length&&(this.edit.studyline.editmode=!0),this.$root.$emit("redrawLines")},updated:function(){this.$root.$emit("redrawLines"),ItemEventBus.$emit("redrawLines")},computed:{columns:function(){return 1+2*this.page.periods},columns_stylerule:function(){for(var s="grid-template-columns: var(--studyplan-filter-width)",i=0;imaxLayer&&(maxLayer=item.layer)}for(var _ix in line.slots[i].filters){var _item=line.slots[i].filters[_ix];_item.layer>maxLayer&&(maxLayer=_item.layer)}}return this.cache.linelayers[line.id]={value:maxLayer+1,timestamp:new Date},maxLayer+1},slotsempty:function(slots){if(Array.isArray(slots)){for(var count=0,i=0;i0&&item.span-i>0&&(show=!1):item.span-i>1&&(show=!1))}}return show}},template:'\n
\n
\n {{ text.studyline_editmode }}\n \n \n \n \n \n \n {{text.edit$core}} \n \n \n {{text.associations}}\n \n \n \n \n
\n
\n \n \n \n
\n
\n\n \x3c!-- Now paint the headings column --\x3e\n
\n \n \n
\n \x3c!-- Next, paint all the cells in the scrollable --\x3e\n
\n
\n \x3c!-- add period information --\x3e\n \n \n \x3c!-- Line by line add the items --\x3e\n \x3c!-- The grid layout handles putting it in rows and columns --\x3e\n