From b60e5065f0e14935a9142c29a5944985342a18ce Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Wed, 5 Jun 2024 22:32:18 +0200 Subject: [PATCH] Code cleanup of eslint warnings --- amd/build/page-edit-plan.min.js | 2 +- amd/build/page-edit-plan.min.js.map | 2 +- amd/build/studyplan-editor-components.min.js | 2 +- amd/build/studyplan-editor-components.min.js.map | 2 +- amd/build/util/mform-helper.min.js | 2 +- amd/build/util/mform-helper.min.js.map | 2 +- amd/src/studyplan-editor-components.js | 12 ++++++------ 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/amd/build/page-edit-plan.min.js b/amd/build/page-edit-plan.min.js index 2fb9457..aa3e8a6 100644 --- a/amd/build/page-edit-plan.min.js +++ b/amd/build/page-edit-plan.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-edit-plan",["exports","core/str","core/ajax","core/notification","./vue/vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./util/debugger","./util/browserbuttonevents","./util/string-helper","./studyplan-processor","./downloader","./util/date-helper","./util/premium","./util/mform-helper","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_browserbuttonevents,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_premium,_mformHelper,_portalVue,_bootstrapVue){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid,options){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;debug.info("options",options),null===options||"object"!=typeof options||Array.isArray(options)?options={defaultAggregation:"core"}:options.defaultAggregation||(options.defaultAggregation="core");let app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",idnumber:"",slots:4,startdate:"2020-08-01",enddate:"",context:contextid,aggregation:options.defaultAggregation,aggregation_config:""}},activestudyplan:null,activepage:null,loadingstudyplan:!1,studyplans:[],templatecount:0,text:strings.studyplan,usedcontexts:[]},created(){this.$root.$on("studyplanRemoved",(studyplan=>{app.activestudyplan==studyplan&&(app.activestudyplan=null);let index=null;for(let idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted(){this.initialize(),(0,_browserbuttonevents.addBrowserButtonEvent)(this.backPressed)},beforeunmount(){},computed:{premiumenabled:_premium.premiumenabled,dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},methods:{backPressed(){debug.log("Back button pressed"),app.activestudyplan&&(debug.log("Closing studyplan"),this.closeStudyplan())},initialize(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].then((function(response){const timingval={future:0,present:1,past:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b);let t=timingval[timinga]-timingval[timingb];return 0==t&&(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime(),0==t&&(t=a.name.localeCompare(b.name))),t})),app.studyplans=response;const hash=location.hash.replace("#","");if(hash){const id=hash;for(const p of app.studyplans)if(p.id==id){app.selectStudyplan(id);break}}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_available_categories",args:{operation:"edit",refcontext_id:contextid}}])[0].then((function(response){app.usedcontexts=response})).catch(_notification.default.exception),this.refreshTemplateCount()},refreshTemplateCount(){(0,_ajax.call)([{methodname:"local_treestudyplan_count_templates",args:{}}])[0].then((function(response){app.templatecount=response})).catch(_notification.default.exception)},closeStudyplan(){app.activestudyplan=null,window.location.hash=""},movedStudyplan(plan,from,to){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),setTimeout((()=>{window.location.search=params.toString()}),50)},onStudyPlanCreated(newstudyplan){if(newstudyplan.context_id!=contextid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",newstudyplan.context_id),resetAllFormDirtyStates(),window.location=window.location.pathname+"?"+params.toString()+"#"+newstudyplan.id}else app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan.id)},switchContext(ctxid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",ctxid),setTimeout((()=>{window.location.href=window.location.pathname+"?"+params.toString()}),50)},selectStudyplan(studyplanid){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplanid}}])[0].then((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response),debug.info("studyplan processed"),app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},import_studyplan(){const self=this;(0,_downloader.upload)(((filename,content)=>{(0,_ajax.call)([{methodname:"local_treestudyplan_import_plan",args:{content:content,format:"application/json",context_id:contextid}}])[0].then((function(response){response.success?self.initialize():debug.error("Import failed: ",response.msg)})).catch(_notification.default.exception)}),"application/json")},export_plan(plan,format){null!=format&&["json","csv"].includes(format)||(format="json"),(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:plan.id,format:format}}])[0].then((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).catch(_notification.default.exception)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_mformHelper=_interopRequireDefault(_mformHelper),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue);var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_mformHelper.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);const debug=new _debugger.default("treestudyplan");let resetAllFormDirtyStates=()=>{};("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require(["core_form/changechecker"],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require("core_form/changechecker")):Promise.resolve(_systemImportTransformerGlobalIdentifier["core_form/changechecker"])).then((ns=>{debug.info(ns),ns.resetAllFormDirtyStates&&(resetAllFormDirtyStates=ns.resetAllFormDirtyStates)})).catch((()=>{}));let strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder",advanced_import_from_file:"advanced_import_from_file",advanced_create_from_template:"advanced_create_from_template",studyplan_add:"studyplan_add"}})})); +define("local_treestudyplan/page-edit-plan",["exports","core/str","core/ajax","core/notification","./vue/vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./util/debugger","./util/browserbuttonevents","./util/string-helper","./studyplan-processor","./downloader","./util/date-helper","./util/premium","./util/mform-helper","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_browserbuttonevents,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_premium,_mformHelper,_portalVue,_bootstrapVue){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid,options){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;debug.info("options",options),null===options||"object"!=typeof options||Array.isArray(options)?options={defaultAggregation:"core"}:options.defaultAggregation||(options.defaultAggregation="core");let app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",idnumber:"",slots:4,startdate:"2020-08-01",enddate:"",context:contextid,aggregation:options.defaultAggregation,aggregation_config:""}},activestudyplan:null,activepage:null,loadingstudyplan:!1,studyplans:[],templatecount:0,text:strings.studyplan,usedcontexts:[]},created(){this.$root.$on("studyplanRemoved",(studyplan=>{app.activestudyplan==studyplan&&(app.activestudyplan=null);let index=null;for(let idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted(){this.initialize(),(0,_browserbuttonevents.addBrowserButtonEvent)(this.backPressed)},beforeunmount(){},computed:{premiumenabled:_premium.premiumenabled,dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},methods:{backPressed(){debug.log("Back button pressed"),app.activestudyplan&&(debug.log("Closing studyplan"),this.closeStudyplan())},initialize(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].then((function(response){const timingval={future:0,present:1,past:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b);let t=timingval[timinga]-timingval[timingb];return 0==t&&(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime(),0==t&&(t=a.name.localeCompare(b.name))),t})),app.studyplans=response;const hash=location.hash.replace("#","");if(hash){const id=hash;for(const p of app.studyplans)if(p.id==id){app.selectStudyplan(id);break}}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_available_categories",args:{operation:"edit",refcontext_id:contextid}}])[0].then((function(response){app.usedcontexts=response})).catch(_notification.default.exception),this.refreshTemplateCount()},refreshTemplateCount(){(0,_ajax.call)([{methodname:"local_treestudyplan_count_templates",args:{}}])[0].then((function(response){app.templatecount=response})).catch(_notification.default.exception)},closeStudyplan(){app.activestudyplan=null,window.location.hash=""},movedStudyplan(plan,from,to){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),setTimeout((()=>{window.location.search=params.toString()}),50)},onStudyPlanCreated(newstudyplan){if(newstudyplan.context_id!=contextid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",newstudyplan.context_id),resetAllFormDirtyStates(),window.location=window.location.pathname+"?"+params.toString()+"#"+newstudyplan.id}else app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan.id)},switchContext(ctxid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",ctxid),setTimeout((()=>{window.location.href=window.location.pathname+"?"+params.toString()}),50)},selectStudyplan(studyplanid){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplanid}}])[0].then((function(response){app.activestudyplan=(0,_studyplanProcessor.processStudyplan)(response),debug.info("studyplan processed"),app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},import_studyplan(){const self=this;(0,_downloader.upload)(((filename,content)=>{(0,_ajax.call)([{methodname:"local_treestudyplan_import_plan",args:{content:content,format:"application/json",context_id:contextid}}])[0].then((function(response){response.success?self.initialize():debug.error("Import failed: ",response.msg)})).catch(_notification.default.exception)}),"application/json")},export_plan(plan,format){null!=format&&["json","csv"].includes(format)||(format="json"),(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:plan.id,format:format}}])[0].then((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).catch(_notification.default.exception)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_mformHelper=_interopRequireDefault(_mformHelper),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue);var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_mformHelper.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);const debug=new _debugger.default("treestudyplan");let resetAllFormDirtyStates=()=>{};("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require(["core_form/changechecker"],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require("core_form/changechecker")):Promise.resolve(_systemImportTransformerGlobalIdentifier["core_form/changechecker"])).then((ns=>{debug.info(ns),ns.resetAllFormDirtyStates&&(resetAllFormDirtyStates=ns.resetAllFormDirtyStates)})).catch((()=>{}));let strings=(0,_stringHelper.loadStrings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder",advanced_import_from_file:"advanced_import_from_file",advanced_create_from_template:"advanced_create_from_template",studyplan_add:"studyplan_add"}})})); //# sourceMappingURL=page-edit-plan.min.js.map \ No newline at end of file diff --git a/amd/build/page-edit-plan.min.js.map b/amd/build/page-edit-plan.min.js.map index 71b74a5..accce26 100644 --- a/amd/build/page-edit-plan.min.js.map +++ b/amd/build/page-edit-plan.min.js.map @@ -1 +1 @@ -{"version":3,"file":"page-edit-plan.min.js","sources":["../src/page-edit-plan.js"],"sourcesContent":["/* eslint no-var: \"error\" */\n/* eslint no-unused-vars: \"off\" */\n/* eslint linebreak-style: \"off\" */\n/* eslint no-trailing-spaces: \"off\" */\n/* eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {get_string,get_strings} from 'core/str';\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\n//import {resetAllFormDirtyStates} from 'core_form/changechecker'; // Moodle 4.00+ only\n\nimport Vue from './vue/vue';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\nimport Debugger from './util/debugger';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\nimport {studyplanTiming} from './util/date-helper';\nimport { premiumenabled, premiumstatus } from \"./util/premium\";\nimport mFormComponents from \"./util/mform-helper\";\nVue.use(mFormComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nconst debug = new Debugger(\"treestudyplan\");\n\nlet resetAllFormDirtyStates = () => {};\nimport('core_form/changechecker').then((ns) => {\n debug.info(ns);\n if(ns.resetAllFormDirtyStates) {\n resetAllFormDirtyStates = ns.resetAllFormDirtyStates;\n }\n}).catch(()=>{});\n\n\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n advanced_import_from_file: 'advanced_import_from_file',\n advanced_create_from_template: 'advanced_create_from_template',\n studyplan_add: \"studyplan_add\",\n },\n});\n\n/**\n * Initialize the Page\n * @param {int} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)\n * @param {object} options Options to be passed to this script\n */\nexport function init(contextid,categoryid,options) {\n // Make sure the id's are numeric and integer\n if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;}\n else { contextid = Number(contextid);} // ensure a numeric value instead of string\n if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;}\n else { categoryid = Number(categoryid);} // ensure a numeric value instead of string\n\n debug.info(\"options\",options);\n if ( options !== null && typeof options === 'object' && !Array.isArray(options) ) {\n if ( !options.defaultAggregation ) {\n options.defaultAggregation = \"core\";\n }\n \n } else {\n options = { defaultAggregation: \"core\"};\n }\n\n // Setup the initial Vue app for this page\n let app = new Vue({\n el: '#root',\n data: {\n create: {\n studyplan: {\n name: '',\n shortname: '',\n description: '',\n idnumber: '',\n slots : 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: options.defaultAggregation,\n aggregation_config: '',\n }\n },\n\n activestudyplan: null,\n activepage: null,\n loadingstudyplan: false,\n studyplans: [],\n templatecount: 0,\n\n text: strings.studyplan,\n usedcontexts: [],\n },\n created() {\n this.$root.$on('studyplanRemoved',(studyplan)=>{\n\n if(app.activestudyplan == studyplan){\n app.activestudyplan = null;\n }\n\n // remove studyplan from index list\n let index = null;\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == studyplan.id){\n index = idx;\n break;\n }\n }\n if(index){\n app.studyplans.splice(index, 1);\n }\n\n });\n },\n mounted() {\n this.initialize();\n addBrowserButtonEvent(this.backPressed);\n },\n beforeunmount() {\n\n },\n computed: {\n premiumenabled,\n dropdown_title(){\n if(this.activestudyplan && this.activestudyplan.name){\n return this.activestudyplan.name;\n }\n else{\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid(){\n return contextid;\n },\n\n },\n methods: {\n backPressed() {\n debug.log(\"Back button pressed\");\n if (app.activestudyplan) {\n debug.log(\"Closing studyplan\");\n this.closeStudyplan();\n }\n },\n initialize() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: { context_id: contextid}\n }])[0].then(function(response){\n const timingval = { future: 0, present: 1, past: 2, };\n response.sort((a,b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n \n let t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by start date if timing is equal\n t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();\n \n if (t == 0) {\n // sort by name if timing is equal\n t = a.name.localeCompare(b.name);\n }\n }\n return t;\n });\n app.studyplans = response;\n \n // load studyplan from hash if applicable\n const hash = location.hash.replace('#','');\n if(hash){\n const id = hash;\n for(const p of app.studyplans) {\n if (p.id == id) {\n app.selectStudyplan(id);\n break;\n }\n }\n }\n }).catch(notification.exception);\n\n call([{\n methodname: 'local_treestudyplan_list_available_categories',\n args: { operation: 'edit', refcontext_id: contextid}\n }])[0].then(function(response){\n app.usedcontexts = response;\n }).catch(notification.exception);\n\n this.refreshTemplateCount();\n },\n refreshTemplateCount(){\n call([{\n methodname: 'local_treestudyplan_count_templates',\n args: { }\n }])[0].then(function(response){\n app.templatecount = response;\n }).catch(notification.exception);\n },\n closeStudyplan() {\n app.activestudyplan = null;\n window.location.hash = '';\n },\n movedStudyplan(plan,from,to) {\n // reload the page in the new context (needed, since a number of links are not reactive in the page)\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", to);\n setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location.search = params.toString();\n },50);\n },\n onStudyPlanCreated(newstudyplan){\n if (newstudyplan.context_id != contextid) {\n // Study plan has changed context id - reload page into new context id and show the plan\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", newstudyplan.context_id);\n // Make sure the form is no longer dirty before reloading the page - avoid beforeunload handler triggering.\n resetAllFormDirtyStates();\n window.location = window.location.pathname + \"?\" + params.toString() + \"#\" + newstudyplan.id;\n } else {\n app.studyplans.push(newstudyplan);\n app.selectStudyplan(newstudyplan.id);\n }\n },\n switchContext(ctxid){\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set('contextid', ctxid);\n setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location.href = window.location.pathname + \"?\" + params.toString();\n },50);\n },\n selectStudyplan(studyplanid){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplanid}\n }])[0].then(function(response){\n app.activestudyplan = ProcessStudyplan(response);\n debug.info('studyplan processed');\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n import_studyplan(){\n const self = this;\n upload((filename,content)=>{\n call([{\n methodname: 'local_treestudyplan_import_plan',\n args: {\n content: content,\n format: \"application/json\",\n context_id: contextid,\n },\n }])[0].then(function(response){\n if(response.success){\n self.initialize();\n } else {\n debug.error(\"Import failed: \",response.msg);\n }\n\n }).catch(notification.exception);\n }, \"application/json\");\n },\n export_plan(plan,format){\n let self = this;\n if(format == undefined || ![\"json\",\"csv\"].includes(format)){\n format = \"json\";\n }\n call([{\n methodname: 'local_treestudyplan_export_plan',\n args: {\n studyplan_id: plan.id,\n format: format\n },\n }])[0].then(function(response){\n\n download(plan.shortname+\".json\",response.content,response.format);\n }).catch(notification.exception);\n },\n \n },\n });\n}\n\n"],"names":["contextid","categoryid","options","undefined","Number","isInteger","debug","info","Array","isArray","defaultAggregation","app","Vue","el","data","create","studyplan","name","shortname","description","idnumber","slots","startdate","enddate","context","aggregation","aggregation_config","activestudyplan","activepage","loadingstudyplan","studyplans","templatecount","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","initialize","this","backPressed","beforeunmount","computed","premiumenabled","dropdown_title","studyplan_select_placeholder","methods","log","closeStudyplan","methodname","args","context_id","then","response","timingval","future","present","past","sort","a","b","timinga","timingb","t","Date","getTime","localeCompare","hash","location","replace","p","selectStudyplan","catch","notification","exception","operation","refcontext_id","refreshTemplateCount","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","setTimeout","toString","onStudyPlanCreated","newstudyplan","resetAllFormDirtyStates","pathname","push","switchContext","ctxid","href","studyplanid","error","import_studyplan","self","filename","content","format","success","msg","export_plan","includes","studyplan_id","use","EditorComponents","TSComponents","ModalComponents","mFormComponents","PortalVue","BootstrapVue","Debugger","ns","advanced_import_from_file","advanced_create_from_template","studyplan_add"],"mappings":"gvBAoEqBA,UAAUC,WAAWC,SAEiDF,eAApFG,IAAcH,YAAcI,OAAOC,UAAUD,OAAOJ,aAAeA,UAAY,EAAiB,EAChFI,OAAOJ,WAEnBC,gBADJE,IAAcF,YAAeG,OAAOC,UAAUD,OAAOH,aACpCG,OAAOH,YADyD,EAGpFK,MAAMC,KAAK,UAAUL,SACJ,OAAZA,SAAuC,iBAAZA,SAAyBM,MAAMC,QAAQP,SAMnEA,QAAU,CAAEQ,mBAAoB,QAL1BR,QAAQQ,qBACVR,QAAQQ,mBAAqB,YAQjCC,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,OAAQ,CACJC,UAAW,CACPC,KAAM,GACNC,UAAW,GACXC,YAAa,GACbC,SAAU,GACVC,MAAQ,EACRC,UAAW,aACXC,QAAS,GACTC,QAASxB,UACTyB,YAAavB,QAAQQ,mBACrBgB,mBAAoB,KAI5BC,gBAAiB,KACjBC,WAAY,KACZC,kBAAkB,EAClBC,WAAY,GACZC,cAAe,EAEfC,KAAMC,QAAQjB,UACdkB,aAAc,IAElBC,eACSC,MAAMC,IAAI,oBAAoBrB,YAE5BL,IAAIgB,iBAAmBX,YACtBL,IAAIgB,gBAAkB,UAItBW,MAAQ,SACR,IAAIC,OAAO5B,IAAImB,cACZnB,IAAImB,WAAWS,KAAKC,IAAMxB,UAAUwB,GAAG,CACtCF,MAAQC,UAIbD,OACC3B,IAAImB,WAAWW,OAAOH,MAAO,OAKzCI,eACSC,4DACiBC,KAAKC,cAE/BC,kBAGAC,SAAU,CACNC,eAAAA,wBACAC,wBACOL,KAAKjB,iBAAmBiB,KAAKjB,gBA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B,CAAC,OAAO,OAAOI,SAASJ,UAC/CA,OAAS,uBAER,CAAC,CACEvD,WAAY,kCACZC,KAAM,CACF2D,aAAc7B,KAAK7C,GACnBqE,OAAQA,WAEZ,GAAGpD,MAAK,SAASC,mCAER2B,KAAKnE,UAAU,QAAQwC,SAASkD,QAAQlD,SAASmD,WAC3DhC,MAAMC,sBAAaC,muBAjStCoC,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,oCAUJH,IAAII,mCAGJJ,IAAIK,iCAEJL,IAAIM,6BAGFnH,MAAQ,IAAIoH,kBAAS,qBAEvBzB,wBAA0B,+nBACIxC,MAAMkE,KACpCrH,MAAMC,KAAKoH,IACRA,GAAG1B,0BACFA,wBAA0B0B,GAAG1B,4BAElCpB,OAAM,aAIL5C,SAAU,8BAAa,CACvBjB,UAAW,CACPkC,6BAA8B,+BAC9B0E,0BAA2B,4BAC3BC,8BAA+B,gCAC/BC,cAAe"} \ No newline at end of file +{"version":3,"file":"page-edit-plan.min.js","sources":["../src/page-edit-plan.js"],"sourcesContent":["/* eslint no-var: \"error\" */\n/* eslint no-unused-vars: \"off\" */\n/* eslint linebreak-style: \"off\" */\n/* eslint no-trailing-spaces: \"off\" */\n/* eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {get_string,get_strings} from 'core/str';\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\n//import {resetAllFormDirtyStates} from 'core_form/changechecker'; // Moodle 4.00+ only\n\nimport Vue from './vue/vue';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\nimport Debugger from './util/debugger';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\nimport {studyplanTiming} from './util/date-helper';\nimport { premiumenabled, premiumstatus } from \"./util/premium\";\nimport mFormComponents from \"./util/mform-helper\";\nVue.use(mFormComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nconst debug = new Debugger(\"treestudyplan\");\n\nlet resetAllFormDirtyStates = () => {};\nimport('core_form/changechecker').then((ns) => {\n debug.info(ns);\n if(ns.resetAllFormDirtyStates) {\n resetAllFormDirtyStates = ns.resetAllFormDirtyStates;\n }\n}).catch(()=>{});\n\n\n\nlet strings = loadStrings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n advanced_import_from_file: 'advanced_import_from_file',\n advanced_create_from_template: 'advanced_create_from_template',\n studyplan_add: \"studyplan_add\",\n },\n});\n\n/**\n * Initialize the Page\n * @param {int} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)\n * @param {object} options Options to be passed to this script\n */\nexport function init(contextid,categoryid,options) {\n // Make sure the id's are numeric and integer\n if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;}\n else { contextid = Number(contextid);} // ensure a numeric value instead of string\n if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;}\n else { categoryid = Number(categoryid);} // ensure a numeric value instead of string\n\n debug.info(\"options\",options);\n if ( options !== null && typeof options === 'object' && !Array.isArray(options) ) {\n if ( !options.defaultAggregation ) {\n options.defaultAggregation = \"core\";\n }\n \n } else {\n options = { defaultAggregation: \"core\"};\n }\n\n // Setup the initial Vue app for this page\n let app = new Vue({\n el: '#root',\n data: {\n create: {\n studyplan: {\n name: '',\n shortname: '',\n description: '',\n idnumber: '',\n slots : 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: options.defaultAggregation,\n aggregation_config: '',\n }\n },\n\n activestudyplan: null,\n activepage: null,\n loadingstudyplan: false,\n studyplans: [],\n templatecount: 0,\n\n text: strings.studyplan,\n usedcontexts: [],\n },\n created() {\n this.$root.$on('studyplanRemoved',(studyplan)=>{\n\n if(app.activestudyplan == studyplan){\n app.activestudyplan = null;\n }\n\n // remove studyplan from index list\n let index = null;\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == studyplan.id){\n index = idx;\n break;\n }\n }\n if(index){\n app.studyplans.splice(index, 1);\n }\n\n });\n },\n mounted() {\n this.initialize();\n addBrowserButtonEvent(this.backPressed);\n },\n beforeunmount() {\n\n },\n computed: {\n premiumenabled,\n dropdown_title(){\n if(this.activestudyplan && this.activestudyplan.name){\n return this.activestudyplan.name;\n }\n else{\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid(){\n return contextid;\n },\n\n },\n methods: {\n backPressed() {\n debug.log(\"Back button pressed\");\n if (app.activestudyplan) {\n debug.log(\"Closing studyplan\");\n this.closeStudyplan();\n }\n },\n initialize() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: { context_id: contextid}\n }])[0].then(function(response){\n const timingval = { future: 0, present: 1, past: 2, };\n response.sort((a,b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n \n let t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by start date if timing is equal\n t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();\n \n if (t == 0) {\n // sort by name if timing is equal\n t = a.name.localeCompare(b.name);\n }\n }\n return t;\n });\n app.studyplans = response;\n \n // load studyplan from hash if applicable\n const hash = location.hash.replace('#','');\n if(hash){\n const id = hash;\n for(const p of app.studyplans) {\n if (p.id == id) {\n app.selectStudyplan(id);\n break;\n }\n }\n }\n }).catch(notification.exception);\n\n call([{\n methodname: 'local_treestudyplan_list_available_categories',\n args: { operation: 'edit', refcontext_id: contextid}\n }])[0].then(function(response){\n app.usedcontexts = response;\n }).catch(notification.exception);\n\n this.refreshTemplateCount();\n },\n refreshTemplateCount(){\n call([{\n methodname: 'local_treestudyplan_count_templates',\n args: { }\n }])[0].then(function(response){\n app.templatecount = response;\n }).catch(notification.exception);\n },\n closeStudyplan() {\n app.activestudyplan = null;\n window.location.hash = '';\n },\n movedStudyplan(plan,from,to) {\n // reload the page in the new context (needed, since a number of links are not reactive in the page)\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", to);\n setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location.search = params.toString();\n },50);\n },\n onStudyPlanCreated(newstudyplan){\n if (newstudyplan.context_id != contextid) {\n // Study plan has changed context id - reload page into new context id and show the plan\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", newstudyplan.context_id);\n // Make sure the form is no longer dirty before reloading the page - avoid beforeunload handler triggering.\n resetAllFormDirtyStates();\n window.location = window.location.pathname + \"?\" + params.toString() + \"#\" + newstudyplan.id;\n } else {\n app.studyplans.push(newstudyplan);\n app.selectStudyplan(newstudyplan.id);\n }\n },\n switchContext(ctxid){\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set('contextid', ctxid);\n setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location.href = window.location.pathname + \"?\" + params.toString();\n },50);\n },\n selectStudyplan(studyplanid){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplanid}\n }])[0].then(function(response){\n app.activestudyplan = processStudyplan(response);\n debug.info('studyplan processed');\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n import_studyplan(){\n const self = this;\n upload((filename,content)=>{\n call([{\n methodname: 'local_treestudyplan_import_plan',\n args: {\n content: content,\n format: \"application/json\",\n context_id: contextid,\n },\n }])[0].then(function(response){\n if(response.success){\n self.initialize();\n } else {\n debug.error(\"Import failed: \",response.msg);\n }\n\n }).catch(notification.exception);\n }, \"application/json\");\n },\n export_plan(plan,format){\n let self = this;\n if(format == undefined || ![\"json\",\"csv\"].includes(format)){\n format = \"json\";\n }\n call([{\n methodname: 'local_treestudyplan_export_plan',\n args: {\n studyplan_id: plan.id,\n format: format\n },\n }])[0].then(function(response){\n\n download(plan.shortname+\".json\",response.content,response.format);\n }).catch(notification.exception);\n },\n \n },\n });\n}\n\n"],"names":["contextid","categoryid","options","undefined","Number","isInteger","debug","info","Array","isArray","defaultAggregation","app","Vue","el","data","create","studyplan","name","shortname","description","idnumber","slots","startdate","enddate","context","aggregation","aggregation_config","activestudyplan","activepage","loadingstudyplan","studyplans","templatecount","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","initialize","this","backPressed","beforeunmount","computed","premiumenabled","dropdown_title","studyplan_select_placeholder","methods","log","closeStudyplan","methodname","args","context_id","then","response","timingval","future","present","past","sort","a","b","timinga","timingb","t","Date","getTime","localeCompare","hash","location","replace","p","selectStudyplan","catch","notification","exception","operation","refcontext_id","refreshTemplateCount","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","setTimeout","toString","onStudyPlanCreated","newstudyplan","resetAllFormDirtyStates","pathname","push","switchContext","ctxid","href","studyplanid","error","import_studyplan","self","filename","content","format","success","msg","export_plan","includes","studyplan_id","use","EditorComponents","TSComponents","ModalComponents","mFormComponents","PortalVue","BootstrapVue","Debugger","ns","advanced_import_from_file","advanced_create_from_template","studyplan_add"],"mappings":"gvBAoEqBA,UAAUC,WAAWC,SAEiDF,eAApFG,IAAcH,YAAcI,OAAOC,UAAUD,OAAOJ,aAAeA,UAAY,EAAiB,EAChFI,OAAOJ,WAEnBC,gBADJE,IAAcF,YAAeG,OAAOC,UAAUD,OAAOH,aACpCG,OAAOH,YADyD,EAGpFK,MAAMC,KAAK,UAAUL,SACJ,OAAZA,SAAuC,iBAAZA,SAAyBM,MAAMC,QAAQP,SAMnEA,QAAU,CAAEQ,mBAAoB,QAL1BR,QAAQQ,qBACVR,QAAQQ,mBA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,8BAA+B,gCAC/BC,cAAe"} \ No newline at end of file diff --git a/amd/build/studyplan-editor-components.min.js b/amd/build/studyplan-editor-components.min.js index c2aed85..8f2548e 100644 --- a/amd/build/studyplan-editor-components.min.js +++ b/amd/build/studyplan-editor-components.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/studyplan-editor-components",["exports","./simpleline/simpleline","core/ajax","core/notification","./util/string-helper","./util/date-helper","./studyplan-processor","./util/debugger","core/config","./downloader","./util/premium","./util/fittext-vue","./util/settings","./treestudyplan-components","./util/mform-helper","./util/psidebar-vue","./vue-easy-dnd/vue-easy-dnd.esm"],(function(_exports,_simpleline,_ajax,_notification,_stringHelper,_dateHelper,_studyplanProcessor,_debugger,_config,_downloader,_premium,_fittextVue,_settings,_treestudyplanComponents,_mformHelper,_psidebarVue,_vueEasyDnd){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_notification=_interopRequireDefault(_notification),_debugger=_interopRequireDefault(_debugger),_config=_interopRequireDefault(_config),_fittextVue=_interopRequireDefault(_fittextVue),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_mformHelper=_interopRequireDefault(_mformHelper),_psidebarVue=_interopRequireDefault(_psidebarVue);const STUDYPLAN_EDITOR_FIELDS=["name","shortname","description","idnumber","context_id","aggregation","aggregation_config"],PERIOD_EDITOR_FIELDS=["fullname","shortname","startdate","enddate"];var _default={install(Vue){Vue.component("drag",_vueEasyDnd.Drag),Vue.component("drop",_vueEasyDnd.Drop),Vue.component("drop-list",_vueEasyDnd.DropList),Vue.use(_treestudyplanComponents.default),Vue.use(_mformHelper.default),Vue.use(_psidebarVue.default),Vue.use(_fittextVue.default);let debug=new _debugger.default("treestudyplan-editor");function isVisible(elem){return!!(elem.offsetWidth||elem.offsetHeight||elem.getClientRects().length)}const ItemEventBus=new Vue;let stringKeys=(0,_stringHelper.loadStringKeys)({conditions:[{value:"ALL",textkey:"condition_all"},{value:"ANY",textkey:"condition_any"}]}),strings=(0,_stringHelper.loadStrings)({studyplanText:{studyline_editmode:"studyline_editmode",toolbox_toggle:"toolbox_toggle",editmode_modules_hidden:"editmode_modules_hidden",studyline_add:"studyline_add",add:"add@core",edit:"edit@core",delete:"delete@core",studyline_name:"studyline_name",studyline_name_ph:"studyline_name_ph",studyline_shortname:"studyline_shortname",studyline_shortname_ph:"studyline_shortname_ph",studyline_enrollable:"studyline_enrollable",studyline_enrolroles:"studyline_enrolroles",studyline_color:"studyline_color",associations:"associations",associated_cohorts:"associated_cohorts",associated_users:"associated_users",studyline_edit:"studyline_edit",studyplan_name:"studyplan_name",studyplan_name_ph:"studyplan_name_ph",studyplan_shortname:"studyplan_shortname",studyplan_shortname_ph:"studyplan_shortname_ph",studyplan_description:"studyplan_description",studyplan_description_ph:"studyplan_description_ph",studyplan_idnumber:"studyplan_idnumber",studyplan_idnumber_ph:"studyplan_idnumber_ph",studyplan_slots:"studyplan_slots",studyplan_startdate:"studyplan_startdate",studyplan_enddate:"studyplan_enddate",line_enrollable_0:"line_enrollable:0",line_enrollable_1:"line_enrollable:1",line_enrollable_2:"line_enrollable:2",line_enrollable_3:"line_enrollable:3",drophere:"drophere",studylineConfirmRemove:"studyline_confirm_remove",studyplanConfirmRemove:"studyplan_confirm_remove"},studyplanAdvanced:{advanced_tools:"advanced_tools",confirm_cancel:"confirm_cancel",confirm_ok:"confirm_ok",success:"success@core",error:"failed@completion",advanced_converted:"advanced_converted",advanced_skipped:"advanced_skipped",advanced_failed:"advanced_failed",advanced_locked:"advanced_locked",advanced_multiple:"advanced_multiple",advanced_error:"advanced_error",advanced_tools_heading:"advanced_tools_heading",advanced_warning_title:"advanced_warning_title",advanced_warning:"advanced_warning",advanced_pick_scale:"advanced_pick_scale",advanced_course_manipulation_title:"advanced_course_manipulation_title",advanced_bulk_course_timing:"advanced_bulk_course_timing",advanced_bulk_course_timing_desc:"advanced_bulk_course_timing_desc",advanced_force_scale_title:"advanced_force_scale_title",advanced_force_scale_desc:"advanced_force_scale_desc",advanced_force_scale_button:"advanced_force_scale_button",advanced_confirm_header:"advanced_confirm_header",advanced_force_scale_confirm:"advanced_force_scale_confirm",advanced_backup_restore:"advanced_backup_restore",advanced_restore:"advanced_restore",advanced_backup:"advanced_backup",advanced_restore_pages:"advanced_restore_pages",advanced_restore_lines:"advanced_restore_lines",advanced_backup_plan:"advanced_backup_plan",advanced_backup_page:"advanced_backup_page",advanced_export:"advanced_export",advanced_export_csv_plan:"advanced_export_csv_plan",advanced_export_csv_page:"advanced_export_csv_page",advanced_import_from_file:"advanced_import_from_file",advanced_purge:"advanced_purge",advanced_purge_plan:"advanced_purge_plan",advanced_purge_plan_expl:"advanced_purge_plan_expl",advanced_purge_page:"advanced_purge_page",advanced_purge_page_expl:"advanced_purge_page_expl",advanced_cascade_cohortsync_title:"advanced_cascade_cohortsync_title",advanced_cascade_cohortsync_desc:"advanced_cascade_cohortsync_desc",advanced_cascade_cohortsync:"advanced_cascade_cohortsync",currentpage:"currentpage"},studyplanEdit:{studyplanEdit:"studyplanEdit",studyplan_add:"studyplan_add",studyplanpage_add:"studyplanpage_add",studyplanpage_edit:"studyplanpage_edit",info_periodsextended:"studyplanpage_info_periodsextended",warning:"warning@core"},periodEdit:{edit:"period_edit",fullname:"studyplan_name",shortname:"studyplan_shortname",startdate:"studyplan_startdate",enddate:"studyplan_enddate"},courseTiming:{title:"course_timing_title",desc:"course_timing_desc",question:"course_timing_question",warning:"course_timing_warning",timing_ok:"course_timing_ok",timing_off:"course_timing_off",course:"course@core",period:"period",yes:"yes$core",no:"no$core",duration:"duration",years:"years$core",year:"year$core",weeks:"weeks$core",week:"week$core",days:"days$core",day:"day$core",rememberchoice:"course_timing_rememberchoice",hidewarning:"course_timing_hidewarning",periodspan:"course_period_span",periods:"periods",periodspan_desc:"course_period_span_desc"},studyplanAssociate:{associations:"associations",associated_cohorts:"associated_cohorts",associated_users:"associated_users",associated_coaches:"associated_coaches",associate_cohorts:"associate_cohorts",associate_users:"associate_users",associate_coached:"associate_coaches",add_association:"add_association",delete_association:"delete_association",associations_empty:"associations_empty",associations_search:"associations_search",cohorts:"cohorts",users:"users",coaches:"coaches",selected:"selected",name:"name",context:"context",search:"search"},itemText:{select_conditions:"select_conditions",item_configuration:"item_configuration",ok:"ok@core",delete:"delete@core",item_delete_message:"item_delete_message",type_course:"course@core",type_junction:"tool-junction",type_start:"tool-start",type_finish:"tool-finish",type_badge:"tool-badge",type_invalid:"course-invalid"},itemCourseText:{select_conditions:"select_conditions",select_grades:"select_grades",coursetiming_past:"coursetiming_past",coursetiming_present:"coursetiming_present",coursetiming_future:"coursetiming_future",grade_include:"grade_include",grade_require:"grade_require",ok:"ok@core",cancel:"cancel@core",delete:"delete@core",noenddate:"noenddate"},invalid:{error:"error"},completion:{completion_completed:"completion_completed",completion_incomplete:"completion_incomplete",aggregation_all:"aggregation_all",aggregation_any:"aggregation_any",aggregation_overall_all:"aggregation_overall_all",aggregation_overall_any:"aggregation_overall_any",completion_not_configured:"completion_not_configured",configure_completion:"configure_completion"},competency:{competency_not_configured:"competency_not_configured",configure_competency:"configure_competency",when:"when",required:"required",points:"points@core_grades",heading:"competency_heading",details:"competency_details"},badge:{share_badge:"share_badge",dateissued:"dateissued",dateexpire:"dateexpire",badgeinfo:"badgeinfo"},toolbox:{toolbox:"toolbox",toolbarRight:"toolbar-right",courses:"courses",flow:"flow",toolJunction:"tool-junction",toolFinish:"tool-finish",toolStart:"tool-start",badges:"badges",relatedbages:"relatedbages@badges",filter:"filter@core",sitebadges:"sitebadges@badges"}});Vue.component("t-studyplan-advanced",{props:{value:{type:Object,default:()=>null},selectedpage:{type:Object,default:()=>null}},data:()=>({forceScales:{selectedScale:null,result:[]},text:strings.studyplanAdvanced}),computed:{scales(){return[{id:null,disabled:!0,name:this.text.advanced_pick_scale}].concat(this.value.advanced.force_scales.scales)}},methods:{forceScalesStart(){const self=this;this.$bvModal.msgBoxConfirm(this.text.advanced_force_scale_confirm,{title:this.text.advanced_force_scale_confirm,okVariant:"danger",okTitle:this.text.confirm_ok,cancelTitle:this.text.confirm_cancel}).then((value=>{1==value&&(0,_ajax.call)([{methodname:"local_treestudyplan_force_studyplan_scale",args:{studyplan_id:this.value.id,scale_id:this.forceScales.selectedScale}}])[0].then((response=>{self.forceScales.result=response})).catch(_notification.default.exception)})).catch(_notification.default.exception)},exportPage(format){const self=this;null!=format&&["json","csv"].includes(format)||(format="json"),(0,_ajax.call)([{methodname:"local_treestudyplan_export_page",args:{page_id:this.selectedpage.id,format:format}}])[0].then((response=>{(0,_downloader.download)(self.value.shortname+".page."+format,response.content,response.format)})).catch(_notification.default.exception)},exportPlan(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:this.value.id,format:"json"}}])[0].then((response=>{(0,_downloader.download)(self.value.shortname+".plan.json",response.content,response.format)})).catch(_notification.default.exception)},bulkCourseTiming(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_bulk_course_timing",args:{page_id:this.selectedpage.id}}])[0].then((response=>{response.success?location.reload():(self.$bvModal.msgBoxOk(response.msg,{title:"Could not set bulk course timing"}),debug.error("Could not set bulk course timing: ",response.msg))})).catch(_notification.default.exception)},importStudylines(){const self=this;(0,_downloader.upload)(((filename,content)=>{(0,_ajax.call)([{methodname:"local_treestudyplan_import_studylines",args:{page_id:this.selectedpage.id,content:content,format:"application/json"}}])[0].then((response=>{response.success?location.reload():(self.$bvModal.msgBoxOk(response.msg,{title:"Import failed"}),debug.error("Import failed: ",response.msg))})).catch(_notification.default.exception)}),"application/json")},importPages(){const self=this;(0,_downloader.upload)(((filename,content)=>{(0,_ajax.call)([{methodname:"local_treestudyplan_import_pages",args:{studyplan_id:this.value.id,content:content,format:"application/json"}}])[0].then((response=>{response.success?location.reload():(self.$bvModal.msgBoxOk(response.msg,{title:"Import failed"}),debug.error("Import failed: ",response.msg))})).catch(_notification.default.exception)}),"application/json")},purgeStudyplan(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_delete_studyplan",args:{id:this.value.id,force:!0}}])[0].then((response=>{response.success?location.reload():(self.$bvModal.msgBoxOk(response.msg,{title:"Could not delete plan "}),debug.error("Could not delete plan: ",response.msg))})).catch(_notification.default.exception)},purgeStudyplanpage(){const self=this;this.selectedpage&&(0,_ajax.call)([{methodname:"local_treestudyplan_delete_studyplanpage",args:{id:this.selectedpage.id,force:!0}}])[0].then((response=>{response.success?location.reload():(self.$bvModal.msgBoxOk(response.msg,{title:"Could not delete page"}),debug.error("Could not delete page: ",response.msg))})).catch(_notification.default.exception)},cascadeCohortsync(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_cascade_cohortsync",args:{studyplan_id:this.value.id}}])[0].then((response=>{self.$bvModal.msgBoxOk(response.success?self.text.success:self.text.error,{title:self.text.advanced_cascade_cohortsync})})).catch(_notification.default.exception)},modalClose(){this.forceScales.result=[]}},template:'\n \n {{text.advanced_tools}}\n \n \n \n {{ text.advanced_warning}}\n \n \n

{{ text.advanced_cascade_cohortsync_title}}

\n

{{ text.advanced_cascade_cohortsync_desc}}

\n

{{ text.advanced_cascade_cohortsync}}

\n

{{ text.advanced_bulk_course_timing}}

\n

{{ text.advanced_bulk_course_timing_desc}}

\n

{{text.currentpage}} {{selectedpage.fullname}}

\n

{{ text.advanced_bulk_course_timing}}

\n \n
\n \n

{{ text.advanced_backup }}

\n

{{ text.advanced_backup_page }}\n {{text.currentpage}} {{selectedpage.fullname}}

\n

{{ text.advanced_backup_plan }}

\n

{{ text.advanced_restore }}

\n

{{ text.advanced_restore_lines}}

\n

{{ text.advanced_restore_pages }}

\n

{{ text.advanced_export }}

\n

{{ text.advanced_export_csv_page }}\n {{text.currentpage}} {{selectedpage.fullname}}

\n
\n \n

{{text.advanced_purge_page_expl}}

\n

{{text.currentpage}} {{selectedpage.fullname}}

\n

{{ text.advanced_purge_page}}

\n

{{text.advanced_purge_plan_expl}}

\n

{{ text.advanced_purge_plan}}

\n
\n
\n
\n
\n '}),Vue.component("t-studyplan-edit",{props:{value:{type:Object,default:()=>null},mode:{type:String,default:()=>"edit"},type:{type:String,default:()=>"link"},variant:{type:String,default:()=>""},contextid:{type:Number,default:1}},data:()=>({text:strings.studyplanEdit}),computed:{},methods:{planSaved(updatedplan){const self=this;if(debug.info("Got new plan data",updatedplan),"create"==self.mode)self.$emit("created",updatedplan);else{const movedFrom=self.value.context_id,movedTo=updatedplan.context_id,moved=movedFrom!=movedTo;updatedplan.pages[0].periods!=self.value.pages[0].periods?(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:self.value.id}}])[0].then((response=>{self.value=(0,_studyplanProcessor.processStudyplan)(response,!0),debug.info("studyplan processed"),self.$emit("input",self.value)})).catch((function(error){_notification.default.exception(error)})):((0,_studyplanProcessor.objCopy)(self.value,updatedplan,STUDYPLAN_EDITOR_FIELDS),self.$emit("input",self.value),moved&&self.$emit("moved",self.value,movedFrom,movedTo))}}},template:'\n \n \n \n '}),Vue.component("t-studyplan-page-edit",{props:{value:{type:Object,default:()=>null},mode:{type:String,default:()=>"edit"},type:{type:String,default:()=>"link"},variant:{type:String,default:()=>""},studyplan:{type:Object}},data:()=>({text:strings.studyplanEdit}),computed:{},methods:{planSaved(updatedpage){const self=this;if("create"==self.mode)self.$emit("created",updatedpage);else{const page=(0,_studyplanProcessor.processStudyplanPage)(updatedpage);debug.info("studyplan page processed"),self.value.periods\n \n \n '}),Vue.component("t-studyplan-associate",{props:["value"],data:()=>({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:[],coaches:[]},loading:{cohorts:!1,users:!1,coaches:!1},search:{users:[],cohorts:[],coaches:[]},selected:{search:{users:[],cohorts:[],coaches:[]},associated:{users:[],cohorts:[],coaches:[]}},text:strings.studyplanAssociate}),methods:{premiumenabled:_premium.premiumenabled,showModal(){this.show=!0,this.loadAssociations()},cohortOptionModel:c=>({value:c.id,text:c.name+" ("+c.context.path.join(" / ")+")"}),userOptionModel:u=>({value:u.id,text:u.firstname+" "+u.lastname}),loadAssociations(){const 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].then((response=>{self.association.users=response.map(self.userOptionModel),self.loading.users=!1})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_associated_cohorts",args:{studyplan_id:self.value.id}}])[0].then((response=>{self.association.cohorts=response.map(self.cohortOptionModel),self.loading.cohorts=!1})).catch(_notification.default.exception),(0,_premium.premiumenabled)()&&(self.loading.coaches=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_associated_coaches",args:{studyplan_id:self.value.id}}])[0].then((response=>{self.association.coaches=response.map(self.userOptionModel),self.loading.coaches=!1})).catch(_notification.default.exception))},searchCohorts(searchtext){const self=this;searchtext.length>0?(0,_ajax.call)([{methodname:"local_treestudyplan_list_cohort",args:{like:searchtext,studyplan_id:self.value.id}}])[0].then((response=>{self.search.cohorts=response.map(self.cohortOptionModel)})).catch(_notification.default.exception):self.search.cohorts=[]},cohortAssociate(){const self=this;const associated=self.association.cohorts,search=self.search.cohorts,searchselected=self.selected.search.cohorts;for(const i in searchselected){const r=searchselected[i];(0,_ajax.call)([{methodname:"local_treestudyplan_connect_cohort",args:{studyplan_id:self.value.id,cohort_id:r}}]).then((response=>{response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)})).catch(_notification.default.exception)}(0,_ajax.call)([])},cohortDisassociate(){const self=this,associatedselected=self.selected.associated.cohorts,associated=self.association.cohorts,search=self.search.cohorts;for(const i in associatedselected){const r=associatedselected[i];(0,_ajax.call)([{methodname:"local_treestudyplan_disconnect_cohort",args:{studyplan_id:self.value.id,cohort_id:r}}])[0].then((response=>{response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)})).catch(_notification.default.exception)}},searchUsers(searchtext){const self=this;searchtext.length>0?(0,_ajax.call)([{methodname:"local_treestudyplan_find_user",args:{like:searchtext,studyplan_id:self.value.id}}])[0].then((response=>{self.search.users=response.map(self.userOptionModel)})).catch(_notification.default.exception):self.search.users=[]},userAssociate(){const self=this,associated=self.association.users,search=self.search.users,searchselected=self.selected.search.users;for(const i in searchselected){const r=searchselected[i];(0,_ajax.call)([{methodname:"local_treestudyplan_connect_user",args:{studyplan_id:self.value.id,user_id:r}}]).then((response=>{response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)})).catch(_notification.default.exception)}},userDisassociate(){const self=this,associated=self.association.users,associatedselected=self.selected.associated.users,search=self.search.users;for(const i in associatedselected){const r=associatedselected[i];(0,_ajax.call)([{methodname:"local_treestudyplan_disconnect_user",args:{studyplan_id:self.value.id,user_id:r}}])[0].then((response=>{response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)})).catch(_notification.default.exception)}},searchCoaches(searchtext){if((0,_premium.premiumenabled)()){const self=this;searchtext.length>0?(0,_ajax.call)([{methodname:"local_treestudyplan_find_coach",args:{like:searchtext,studyplan_id:self.value.id}}])[0].then((response=>{self.search.coaches=response.map(self.userOptionModel)})).catch(_notification.default.exception):self.search.coaches=[]}},coachAssociate(){if((0,_premium.premiumenabled)()){const self=this,associated=self.association.coaches,search=self.search.coaches,searchselected=self.selected.search.coaches;for(const i in searchselected){const r=searchselected[i];(0,_ajax.call)([{methodname:"local_treestudyplan_connect_coach",args:{studyplan_id:self.value.id,user_id:r}}]).then((response=>{response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)})).catch(_notification.default.exception)}}},coachDisassociate(){if((0,_premium.premiumenabled)()){const self=this,associated=self.association.coaches,associatedselected=self.selected.associated.coaches,search=self.search.coaches;for(const i in associatedselected){const r=associatedselected[i];(0,_ajax.call)([{methodname:"local_treestudyplan_disconnect_coach",args:{studyplan_id:self.value.id,user_id:r}}])[0].then((response=>{response.success&&(0,_studyplanProcessor.transportItem)(associated,search,r)})).catch(_notification.default.exception)}}}},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 {{text.associated_coaches}}\n {{text.associate_coaches}}\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:()=>null},type:{type:String,default:()=>"link"},variant:{type:String,default:()=>""},minstart:{type:String,default:()=>null},maxend:{type:String,default:()=>null}},data:()=>({show:!1,editdata:{fullname:"",shortname:"",startdate:(new Date).getFullYear()+"-08-01",enddate:(new Date).getFullYear()+1+"-08-01"},text:strings.periodEdit}),methods:{editStart(){(0,_studyplanProcessor.objCopy)(this.editdata,this.value,PERIOD_EDITOR_FIELDS),this.show=!0},editFinish(){const self=this;let args={id:this.value.id};(0,_studyplanProcessor.objCopy)(args,this.editdata,PERIOD_EDITOR_FIELDS),(0,_ajax.call)([{methodname:"local_treestudyplanEdit_period",args:args}])[0].then((response=>{(0,_studyplanProcessor.objCopy)(self.value,response,PERIOD_EDITOR_FIELDS),self.$emit("input",self.value),self.$emit("edited",self.value)})).catch(_notification.default.exception)},refresh(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_get_period",args:{id:this.value.id}}])[0].then((response=>{(0,_studyplanProcessor.objCopy)(self.value,response,PERIOD_EDITOR_FIELDS),self.$emit("input",self.value)})).catch(_notification.default.exception)},addDay:(date,days)=>(void 0===days&&(days=1),(0,_dateHelper.addDays)(date,days)),subDay:(date,days)=>(void 0===days&&(days=1),(0,_dateHelper.addDays)(date,0-days))},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:{type:Object},coaching:{type:Boolean,default:!1}},data:()=>({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",enrol:{enrollable:0,enrolroles:[]}},page:{id:-1,name:"",shortname:""}},edit:{toolbox_shown:!1,studyline:{editmode:!1,data:{name:"",shortname:"",color:"#DDDDDD",enrol:{enrollable:0,enrolroles:[]}},original:{},availableroles:[]},studyplan:{data:{name:"",shortname:"",description:"",slots:4,startdate:"2020-08-01",enddate:"",aggregation:"",aggregation_config:"",aggregation_info:{useRequiredGrades:!0,useItemCondition:!1}},original:{}}},text:strings.studyplanText,cache:{linelayers:{}},selectedpageindex:0,emptyline:{id:-1,name:"",shortname:"",color:"#FF0000",filterslots:[{}],courseslots:[{}]},availableroles:[]}),created(){const self=this;ItemEventBus.$on("coursechange",(()=>{self.$emit("pagechanged",this.selectedpage)}))},mounted(){const self=this;0!=this.value.pages[0].studylines.length||this.coaching||(this.edit.studyline.editmode=!0),self.coaching||(0,_ajax.call)([{methodname:"local_treestudyplan_list_roles",args:{studyplan_id:this.value.id}}])[0].then((response=>{self.availableroles=response})).catch(_notification.default.exception),this.$root.$emit("redrawLines"),this.$emit("pagechanged",this.selectedpage)},updated(){this.$root.$emit("redrawLines"),ItemEventBus.$emit("redrawLines")},computed:{selectedpage(){return this.value.pages[this.selectedpageindex]},hivizdrop:()=>(0,_settings.settings)("hivizdropslots")},methods:{premiumenabled:_premium.premiumenabled,columns:page=>1+2*page.periods,columnsStylerule(page){let s="grid-template-columns: var(--studyplan-filter-width)";for(let i=0;i!!type.item,countLineLayers(line,page){if(this.cache.linelayers[line.id]&&new Date-this.cache.linelayers[line.id].timestamp<1e3)return this.cache.linelayers[line.id].value;{let maxLayer=-1;for(let i=0;i<=page.periods;i++)if(line.slots[i]){for(const ix in line.slots[i].courses){const item=line.slots[i].courses[ix];item.layer>maxLayer&&(maxLayer=item.layer)}for(const ix in line.slots[i].filters){const 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(slots){if(Array.isArray(slots)){let count=0;for(let i=0;i{page.studylines.push(response),newlineinfo.name="",newlineinfo.shortname="",newlineinfo.color="#dddddd",newlineinfo.enrol.enrollable=0,newlineinfo.enrol.enrolroles=[]})).catch(_notification.default.exception)},editLineStart(line){const page=this.value.pages[this.selectedpageindex];debug.info("Starting line edit",line),Object.assign(this.edit.studyline.data,line),this.edit.studyline.original=line,this.$bvModal.show("modal-edit-studyline-"+page.id)},editLineFinish(){let editedline=this.edit.studyline.data,originalline=this.edit.studyline.original;(0,_ajax.call)([{methodname:"local_treestudyplanEdit_studyline",args:{id:editedline.id,name:editedline.name,shortname:editedline.shortname,color:editedline.color,enrollable:editedline.enrol.enrollable,enrolroles:editedline.enrol.enrolroles}}])[0].then((response=>{originalline.name=response.name,originalline.shortname=response.shortname,originalline.color=response.color,originalline.enrol.enrollable=response.enrol.enrollable,originalline.enrol.enrolroles=response.enrol.enrolroles})).catch(_notification.default.exception)},deleteLine(page,line){this.$bvModal.msgBoxConfirm(this.text.studylineConfirmRemove.replace("{$a}",line.name),{okTitle:this.text.delete,okVariant:"danger"}).then((modalresponse=>{modalresponse&&(0,_ajax.call)([{methodname:"local_treestudyplan_delete_studyline",args:{id:line.id}}])[0].then((response=>{if(1==response.success){let index=page.studylines.indexOf(line);page.studylines.splice(index,1)}})).catch(_notification.default.exception)})).catch(_notification.default.exception)},reorderLines(event,lines){event.apply(lines);let sequence=[];for(let idx in lines)sequence.push({id:lines[idx].id,sequence:idx});(0,_ajax.call)([{methodname:"local_treestudyplan_reorder_studylines",args:{sequence:sequence}}])[0].then((()=>{})).catch(_notification.default.exception)},deletePlan(studyplan){const self=this;self.$bvModal.msgBoxConfirm(this.text.studyplabConfirmRemove.replace("{$a}",studyplan.name),{okTitle:this.text.delete,okVariant:"danger"}).then((function(modalresponse){modalresponse&&(0,_ajax.call)([{methodname:"local_treestudyplan_delete_studyplan",args:{id:studyplan.id,force:!0}}])[0].then((response=>{1==response.success&&self.$root.$emit("studyplanRemoved",studyplan)})).catch(_notification.default.exception)})).catch(_notification.default.exception)},deleteStudyItem(event){let item=event.data;(0,_ajax.call)([{methodname:"local_treestudyplan_delete_studyitem",args:{id:item.id}}])[0].then((response=>{1==response.success&&event.source.$emit("cut",event)})).catch(_notification.default.exception)},showslot(page,line,index,layeridx,type){const forGradable="gradable"==type,periods=page.periods;let show=!0;for(let i=0;i0&&item.span-i>0&&(show=!1):item.span-i>1&&(show=!1))}}return show},periodEdited(pi){const prev=this.$refs["periodeditor-"+(pi.period-1)];prev&&prev[0]&&prev[0].refresh();const next=this.$refs["periodeditor-"+(pi.period+1)];next&&next[0]&&next[0].refresh()},addDay:(date,days)=>(void 0===days&&(days=1),(0,_dateHelper.addDays)(date,days)),subDay:(date,days)=>(void 0===days&&(days=1),(0,_dateHelper.addDays)(date,0-days)),toolboxSwitched(event){this.$emit("toggletoolbox",event)},pagecreated(page){this.value.pages.push(page)},selectedpageChanged(newTabIndex){const page=this.value.pages[newTabIndex];this.$emit("pagechanged",page)},sumLineLayers(idx,page){if(idx<0||0==page.studylines.count)return 0;{let sum=0;for(let i=0;i=nextlayer&&(nextlayer=itm.layer+1);(0,_ajax.call)([{methodname:"local_treestudyplan_add_studyitem",args:{line_id:line.id,slot:slot,layer:nextlayer,type:"course",details:{competency_id:null,conditions:"",course_id:event.data.id,badge_id:null,continuation_id:null}}}])[0].then((response=>{let item=response;lineslot.push(item),self.$emit("input",self.value),this.$nextTick((()=>{this.$refs.timingChecker&&this.$refs.timingChecker.validateCoursePeriod()})),ItemEventBus.$emit("coursechange")})).catch(_notification.default.exception)}else if("filter"==event.type.type){debug.info("Adding new filter compenent");const lineslot=line.slots[slot].filters;let nextlayer=0;for(const itm of lineslot)itm.layer>=nextlayer&&(nextlayer=itm.layer+1);(0,_ajax.call)([{methodname:"local_treestudyplan_add_studyitem",args:{line_id:line.id,slot:slot,type:event.data.type,layer:nextlayer,details:{badge_id:event.data.badge?event.data.badge.id:void 0}}}])[0].then((response=>{let item=response;lineslot.push(item),self.$emit("input",self.value)})).catch(_notification.default.exception)}},checkTypeCourse:type=>"gradable"==type.type&&!(!(0,_settings.settings)("hivizdropslots")||type.item),checkTypeFilter:type=>"filter"==type.type&&!(!(0,_settings.settings)("hivizdropslots")||type.item)},template:'\n
\n \n
\n
\n {{ text.studyline_editmode }}\n {{ text.toolbox_toggle}}\n \n \n
\n
\n \n \n \n \n {{text.associations}}\n \n \n {{text.edit}}\n \n \n \n \n
\n
\n \n \n \x3c!-- New Tab Button (Using tabs-end slot) --\x3e\n \n \n \n
\n \n \n \n
\n
\n \x3c!-- Now paint the headings column --\x3e\n
\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