From de970313262ca7b63702b18c80bc48f0a1339b66 Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Tue, 12 Dec 2023 23:44:02 +0100 Subject: [PATCH] Fixed context selection bugs --- amd/build/page-edit-plan.min.js | 2 +- amd/build/page-edit-plan.min.js.map | 2 +- amd/build/page-view-plan.min.js | 2 +- amd/build/page-view-plan.min.js.map | 2 +- amd/build/studyplan-editor-components.min.js | 2 +- .../studyplan-editor-components.min.js.map | 2 +- amd/src/page-edit-plan.js | 27 ++++++++++++++----- amd/src/page-view-plan.js | 6 ++--- amd/src/studyplan-editor-components.js | 11 ++++++++ classes/form/studyplan_editform.php | 4 ++- lang/en/local_treestudyplan.php | 1 + lang/nl/local_treestudyplan.php | 1 + 12 files changed, 45 insertions(+), 17 deletions(-) diff --git a/amd/build/page-edit-plan.min.js b/amd/build/page-edit-plan.min.js index bc535e3..4a1748b 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/string-helper","./studyplan-processor","./downloader","./util/date-helper","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue","./vue-easy-dnd/vue-easy-dnd.esm"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_portalVue,_bootstrapVue,_vueEasyDnd){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}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",editMode:!1}:(options.defaultAggregation||(options.defaultAggregation="core"),options.editMode||(options.editMode=!1));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:""}},toolbox:{shown:!1,right:!0},filters:{systembadges:"",relatedbadges:""},activestudyplan:null,activepage:null,loadingstudyplan:!1,studyplans:[],frameworks:[],relatedbadges:[],systembadges:[],courses:[],text:strings.studyplan,usedcontexts:[],initialEditMode:!!options.editMode},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()},computed:{dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid,filterComponentType:()=>({item:!1,component:!0,span:1,type:"filter"})},methods:{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)for(let idx in app.studyplans)if(app.studyplans[idx].id==hash){app.selectStudyplan(app.studyplans[idx]);break}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_map_categories",args:{}}])[0].then((function(response){app.courses=response})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"edit"}}])[0].then((function(response){app.usedcontexts=response})).catch(_notification.default.exception),this.filter_systembadges()},closeStudyplan(){app.activestudyplan=null,window.location.hash=""},movedStudyplan(plan,from,to){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),window.location.search=params.toString()},onStudyPlanCreated(newstudyplan){app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan)},switchContext(ctx){const params=new URLSearchParams(location.search);params.set("categoryid",ctx.id),window.location.search=params.toString()},selectStudyplan(studyplan){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response),debug.info("studyplan processed"),app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},onPageChange(page){this.activepage=page,this.filter_relatedbadges()},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].done((function(response){response.success?self.initialize():debug.error("Import failed: ",response.msg)})).fail(_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].done((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).fail(_notification.default.exception)},toggletoolbox(event){debug.info(event),this.toolbox.shown=event},filter_systembadges(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_search_badges",args:{search:this.filters.systembadges||""}}])[0].then((function(response){self.systembadges=response})).catch(_notification.default.exception)},filter_relatedbadges(){const self=this;this.activepage&&(0,_ajax.call)([{methodname:"local_treestudyplan_search_related_badges",args:{page_id:this.activepage.id,search:this.filters.relatedbadges||""}}])[0].then((function(response){self.relatedbadges=response})).catch(_notification.default.exception)},reset_systembadges(){this.filters.systembadges="",this.filter_systembadges()},reset_relatedbadges(){this.filters.relatedbadges="",this.filter_relatedbadges()}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default),_vue.default.component("drag",_vueEasyDnd.Drag),_vue.default.component("drop",_vueEasyDnd.Drop),_vue.default.component("drop-list",_vueEasyDnd.DropList);const debug=new _debugger.default("treestudyplan");let strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); +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/string-helper","./studyplan-processor","./downloader","./util/date-helper","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue","./vue-easy-dnd/vue-easy-dnd.esm"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_portalVue,_bootstrapVue,_vueEasyDnd){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}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",editMode:!1}:(options.defaultAggregation||(options.defaultAggregation="core"),options.editMode||(options.editMode=!1));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:""}},toolbox:{shown:!1,right:!0},filters:{systembadges:"",relatedbadges:""},activestudyplan:null,activepage:null,loadingstudyplan:!1,studyplans:[],frameworks:[],relatedbadges:[],systembadges:[],courses:[],text:strings.studyplan,usedcontexts:[],initialEditMode:!!options.editMode},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()},computed:{dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid,filterComponentType:()=>({item:!1,component:!0,span:1,type:"filter"})},methods:{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)for(let idx in app.studyplans)if(app.studyplans[idx].id==hash){app.selectStudyplan(app.studyplans[idx]);break}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_map_categories",args:{}}])[0].then((function(response){app.courses=response})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"edit"}}])[0].then((function(response){app.usedcontexts=response})).catch(_notification.default.exception),this.filter_systembadges()},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),setTimeout((()=>{window.location=window.location.pathname+"?"+params.toString()+"#"+newstudyplan.id}),50)}else app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan)},switchContext(cat){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",cat.context_id),window.location.search=params.toString()},selectStudyplan(studyplan){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response),debug.info("studyplan processed"),app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},onPageChange(page){this.activepage=page,this.filter_relatedbadges()},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].done((function(response){response.success?self.initialize():debug.error("Import failed: ",response.msg)})).fail(_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].done((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).fail(_notification.default.exception)},toggletoolbox(event){debug.info(event),this.toolbox.shown=event},filter_systembadges(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_search_badges",args:{search:this.filters.systembadges||""}}])[0].then((function(response){self.systembadges=response})).catch(_notification.default.exception)},filter_relatedbadges(){const self=this;this.activepage&&(0,_ajax.call)([{methodname:"local_treestudyplan_search_related_badges",args:{page_id:this.activepage.id,search:this.filters.relatedbadges||""}}])[0].then((function(response){self.relatedbadges=response})).catch(_notification.default.exception)},reset_systembadges(){this.filters.systembadges="",this.filter_systembadges()},reset_relatedbadges(){this.filters.relatedbadges="",this.filter_relatedbadges()}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default),_vue.default.component("drag",_vueEasyDnd.Drag),_vue.default.component("drop",_vueEasyDnd.Drop),_vue.default.component("drop-list",_vueEasyDnd.DropList);const debug=new _debugger.default("treestudyplan");let strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); //# 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 1d2780d..93ec7e3 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\nimport Vue from './vue/vue';\n\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';\n\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\nimport {studyplanTiming} from './util/date-helper';\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\nimport {Drag, Drop, DropList} from './vue-easy-dnd/vue-easy-dnd.esm';\nVue.component('drag',Drag);\nVue.component('drop',Drop);\nVue.component('drop-list',DropList);\n\nconst debug = new Debugger(\"treestudyplan\");\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\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 if ( !options.editMode ) {\n options.editMode = false;\n }\n } else {\n options = { defaultAggregation: \"core\", editMode: false};\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 toolbox: {\n shown: false,\n right: true,\n },\n filters: {\n systembadges: \"\",\n relatedbadges: \"\",\n },\n activestudyplan: null,\n activepage: null,\n loadingstudyplan: false,\n studyplans: [],\n frameworks: [],\n relatedbadges: [],\n systembadges: [],\n courses: [],\n text: strings.studyplan,\n usedcontexts: [],\n initialEditMode: !!options.editMode,\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 },\n computed: {\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 filterComponentType(){\n return {\n item: false,\n component: true,\n span: 1,\n type: 'filter',\n };\n },\n },\n methods: {\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 for(let idx in app.studyplans){\n if(app.studyplans[idx].id == hash){\n app.selectStudyplan(app.studyplans[idx]);\n break;\n }\n }\n }\n }).catch(notification.exception);\n call([{\n methodname: 'local_treestudyplan_map_categories',\n args: {}\n }])[0].then(function(response){\n app.courses = response;\n }).catch(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_used_categories',\n args: { operation: 'edit'}\n }])[0].then(function(response){\n app.usedcontexts = response;\n }).catch(notification.exception);\n this.filter_systembadges();\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 window.location.search = params.toString();\n },\n onStudyPlanCreated(newstudyplan){\n app.studyplans.push(newstudyplan);\n app.selectStudyplan(newstudyplan);\n\n },\n switchContext(ctx){\n const params = new URLSearchParams(location.search);\n params.set('categoryid', ctx.id);\n window.location.search = params.toString();\n\n },\n selectStudyplan(studyplan){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplan.id}\n }])[0].done(function(response){\n app.activestudyplan = ProcessStudyplan(response);\n debug.info('studyplan processed');\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n onPageChange(page) {\n this.activepage = page;\n this.filter_relatedbadges();\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].done(function(response){\n if(response.success){\n self.initialize();\n } else {\n debug.error(\"Import failed: \",response.msg);\n }\n\n }).fail(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].done(function(response){\n\n download(plan.shortname+\".json\",response.content,response.format);\n }).fail(notification.exception);\n },\n toggletoolbox(event) {\n debug.info(event);\n this.toolbox.shown = event;\n },\n filter_systembadges() {\n const self = this;\n call([{\n methodname: 'local_treestudyplan_search_badges',\n args: { \n search: this.filters.systembadges || \"\"\n }\n }])[0].then(function(response){\n self.systembadges = response;\n }).catch(notification.exception);\n },\n filter_relatedbadges() {\n const self = this;\n if (this.activepage) {\n call([{\n methodname: 'local_treestudyplan_search_related_badges',\n args: { \n page_id: this.activepage.id,\n search: this.filters.relatedbadges || \"\"\n }\n }])[0].then(function(response){\n self.relatedbadges = response;\n }).catch(notification.exception);\n }\n },\n reset_systembadges() {\n this.filters.systembadges = \"\";\n this.filter_systembadges();\n },\n reset_relatedbadges() {\n this.filters.relatedbadges = \"\";\n this.filter_relatedbadges();\n },\n },\n });\n}\n\n"],"names":["contextid","categoryid","options","undefined","Number","isInteger","debug","info","Array","isArray","defaultAggregation","editMode","app","Vue","el","data","create","studyplan","name","shortname","description","idnumber","slots","startdate","enddate","context","aggregation","aggregation_config","toolbox","shown","right","filters","systembadges","relatedbadges","activestudyplan","activepage","loadingstudyplan","studyplans","frameworks","courses","text","strings","usedcontexts","initialEditMode","created","$root","$on","index","idx","id","splice","mounted","initialize","computed","dropdown_title","this","studyplan_select_placeholder","filterComponentType","item","component","span","type","methods","methodname","args","context_id","then","response","timingval","future","present","past","sort","a","b","timinga","timingb","t","Date","getTime","localeCompare","hash","location","replace","selectStudyplan","catch","notification","exception","operation","filter_systembadges","closeStudyplan","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","toString","onStudyPlanCreated","newstudyplan","push","switchContext","ctx","done","fail","error","onPageChange","page","filter_relatedbadges","import_studyplan","self","filename","content","format","success","msg","export_plan","includes","studyplan_id","toggletoolbox","event","page_id","reset_systembadges","reset_relatedbadges","use","EditorComponents","TSComponents","ModalComponents","PortalVue","BootstrapVue","Drag","Drop","DropList","Debugger"],"mappings":"iwBAsDqBA,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,SAQ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GAAGiC,MAAK,SAASC,UACjB+C,KAAKjF,cAAgBkC,YACtBkB,MAAMC,sBAAaC,YAG9BuC,0BACS/F,QAAQC,aAAe,QACvByD,uBAETsC,2BACShG,QAAQE,cAAgB,QACxB+E,ydAhTjBgB,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,oCASJH,IAAII,iCAEJJ,IAAIK,oCAGJ1E,UAAU,OAAO2E,+BACjB3E,UAAU,OAAO4E,+BACjB5E,UAAU,YAAY6E,4BAEpBlI,MAAQ,IAAImI,kBAAS,qBAEvBhG,SAAU,8BAAa,CACvBxB,UAAW,CACPuC,6BAA8B"} \ 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\nimport Vue from './vue/vue';\n\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';\n\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\nimport {studyplanTiming} from './util/date-helper';\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\nimport {Drag, Drop, DropList} from './vue-easy-dnd/vue-easy-dnd.esm';\nVue.component('drag',Drag);\nVue.component('drop',Drop);\nVue.component('drop-list',DropList);\n\nconst debug = new Debugger(\"treestudyplan\");\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\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 if ( !options.editMode ) {\n options.editMode = false;\n }\n } else {\n options = { defaultAggregation: \"core\", editMode: false};\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 toolbox: {\n shown: false,\n right: true,\n },\n filters: {\n systembadges: \"\",\n relatedbadges: \"\",\n },\n activestudyplan: null,\n activepage: null,\n loadingstudyplan: false,\n studyplans: [],\n frameworks: [],\n relatedbadges: [],\n systembadges: [],\n courses: [],\n text: strings.studyplan,\n usedcontexts: [],\n initialEditMode: !!options.editMode,\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 },\n computed: {\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 filterComponentType(){\n return {\n item: false,\n component: true,\n span: 1,\n type: 'filter',\n };\n },\n },\n methods: {\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 for(let idx in app.studyplans){\n if(app.studyplans[idx].id == hash){\n app.selectStudyplan(app.studyplans[idx]);\n break;\n }\n }\n }\n }).catch(notification.exception);\n call([{\n methodname: 'local_treestudyplan_map_categories',\n args: {}\n }])[0].then(function(response){\n app.courses = response;\n }).catch(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_used_categories',\n args: { operation: 'edit'}\n }])[0].then(function(response){\n app.usedcontexts = response;\n }).catch(notification.exception);\n this.filter_systembadges();\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 setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location = window.location.pathname + \"?\" + params.toString() + \"#\" + newstudyplan.id;\n },50);\n } else {\n app.studyplans.push(newstudyplan);\n app.selectStudyplan(newstudyplan);\n }\n },\n switchContext(cat){\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set('contextid', cat.context_id);\n window.location.search = params.toString();\n },\n selectStudyplan(studyplan){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplan.id}\n }])[0].done(function(response){\n app.activestudyplan = ProcessStudyplan(response);\n debug.info('studyplan processed');\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n onPageChange(page) {\n this.activepage = page;\n this.filter_relatedbadges();\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].done(function(response){\n if(response.success){\n self.initialize();\n } else {\n debug.error(\"Import failed: \",response.msg);\n }\n\n }).fail(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].done(function(response){\n\n download(plan.shortname+\".json\",response.content,response.format);\n }).fail(notification.exception);\n },\n toggletoolbox(event) {\n debug.info(event);\n this.toolbox.shown = event;\n },\n filter_systembadges() {\n const self = this;\n call([{\n methodname: 'local_treestudyplan_search_badges',\n args: { \n search: this.filters.systembadges || \"\"\n }\n }])[0].then(function(response){\n self.systembadges = response;\n }).catch(notification.exception);\n },\n filter_relatedbadges() {\n const self = this;\n if (this.activepage) {\n call([{\n methodname: 'local_treestudyplan_search_related_badges',\n args: { \n page_id: this.activepage.id,\n search: this.filters.relatedbadges || \"\"\n }\n }])[0].then(function(response){\n self.relatedbadges = response;\n }).catch(notification.exception);\n }\n },\n reset_systembadges() {\n this.filters.systembadges = \"\";\n this.filter_systembadges();\n },\n reset_relatedbadges() {\n this.filters.relatedbadges = \"\";\n this.filter_relatedbadges();\n },\n },\n });\n}\n\n"],"names":["contextid","categoryid","options","undefined","Number","isInteger","debug","info","Array","isArray","defaultAggregation","editMode","app","Vue","el","data","create","studyplan","name","shortname","description","idnumber","slots","startdate","enddate","context","aggregation","aggregation_config","toolbox","shown","right","filters","systembadges","relatedbadges","activestudyplan","activepage","loadingstudyplan","studyplans","frameworks","courses","text","strings","usedcontexts","initialEditMode","created","$root","$on","index","idx","id","splice","mounted","initialize","computed","dropdown_title","this","studyplan_select_placeholder","filterComponentType","item","component","span","type","methods","methodname","args","context_id","then","response","timingval","future","present","past","sort","a","b","timinga","timingb","t","Date","getTime","localeCompare","hash","location","replace","selectStudyplan","catch","notification","exception","operation","filter_systembadges","closeStudyplan","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","setTimeout","toString","onStudyPlanCreated","newstudyplan","pathname","push","switchContext","cat","done","fail","error","onPageChange","page","filter_relatedbadges","import_studyplan","self","filename","content","format","success","msg","export_plan","includes","studyplan_id","toggletoolbox","event","page_id","reset_systembadges","reset_relatedbadges","use","EditorComponents","TSComponents","ModalComponents","PortalVue","BootstrapVue","Drag","Drop","DropList","Debugger"],"mappings":"iwBAsDqBA,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,SAQnEA,QAAU,CAAEQ,mBAAoB,OAAQC,UAAU,IAP5CT,Q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C,MAAK,SAASC,UACjBiD,KAAKpF,aAAemC,YACrBkB,MAAMC,sBAAaC,YAE1B2B,6BACUE,KAAO7D,KACTA,KAAKpB,2BACA,CAAC,CACF4B,WAAY,4CACZC,KAAM,CACE+D,QAASxE,KAAKpB,WAAWc,GACzBiD,OAAQ3C,KAAKxB,QAAQE,eAAiB,OAE9C,GAAGiC,MAAK,SAASC,UACjBiD,KAAKnF,cAAgBkC,YACtBkB,MAAMC,sBAAaC,YAG9ByC,0BACSjG,QAAQC,aAAe,QACvByD,uBAETwC,2BACSlG,QAAQE,cAAgB,QACxBiF,ydA7TjBgB,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,oCASJH,IAAII,iCAEJJ,IAAIK,oCAGJ5E,UAAU,OAAO6E,+BACjB7E,UAAU,OAAO8E,+BACjB9E,UAAU,YAAY+E,4BAEpBpI,MAAQ,IAAIqI,kBAAS,qBAEvBlG,SAAU,8BAAa,CACvBxB,UAAW,CACPuC,6BAA8B"} \ No newline at end of file diff --git a/amd/build/page-view-plan.min.js b/amd/build/page-view-plan.min.js index 0e0f1ce..b4981ee 100644 --- a/amd/build/page-view-plan.min.js +++ b/amd/build/page-view-plan.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-view-plan",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-processor","./util/date-helper","./report-viewer-components","./treestudyplan-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_reportViewerComponents,_treestudyplanComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;let app=new _vue.default({el:"#root",data:{displayedstudyplan:null,activestudyplan:null,associatedstudents:[],selectedstudent:null,studentstudyplan:null,loadingstudyplan:!1,studyplans:[],text:strings.studyplan,toolbox:{right:!0},usedcontexts:[]},async mounted(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].done((function(response){const timingval={present:0,past:1,future:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b),t=timingval[timinga]-timingval[timingb];return 0==t?a.name.localeCompare(b.name):t})),app.studyplans=response;const parts=window.location.hash.replace("#","").split("-");if(parts&&parts.length>0)for(let idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1]);break}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"view"}}])[0].done((function(response){const contexts=[];for(const ix in response)response[ix].studyplancount>0&&contexts.push(response[ix]);app.usedcontexts=contexts})).fail(_notification.default.exception)},computed:{dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},methods:{switchContext(ctx){const params=new URLSearchParams(location.search);params.set("categoryid",ctx.id),window.location.search=params.toString()},closeStudyplan(){app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,window.location.hash=""},selectStudyplan(studyplan,studentid){app.loadingstudyplan=!0,app.activestudyplan=null,app.associatedstudents=[],app.selectedstudent=null,app.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),app.displayedstudyplan=app.activestudyplan,app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id,(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated",args:{studyplan_id:studyplan.id}}])[0].done((function(response){if(app.associatedstudents=response,studentid)for(const student of app.associatedstudents)if(student.id==studentid){app.showStudentView(student);break}})).fail(_notification.default.exception)})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){app.selectedstudent=student,app.studentstudyplan=null,app.loadingstudyplan=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_get_user_studyplan",args:{userid:student.id,studyplanid:app.activestudyplan.id}}])[0].done((function(response){app.studentstudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id+"-"+student.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showOverview(){app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,window.location.hash=app.activestudyplan.id}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);new _debugger.default("treestudyplanviewer");let strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); +define("local_treestudyplan/page-view-plan",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-processor","./util/date-helper","./report-viewer-components","./treestudyplan-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_reportViewerComponents,_treestudyplanComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;let app=new _vue.default({el:"#root",data:{displayedstudyplan:null,activestudyplan:null,associatedstudents:[],selectedstudent:null,studentstudyplan:null,loadingstudyplan:!1,studyplans:[],text:strings.studyplan,toolbox:{right:!0},usedcontexts:[]},async mounted(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].done((function(response){const timingval={present:0,past:1,future:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b),t=timingval[timinga]-timingval[timingb];return 0==t?a.name.localeCompare(b.name):t})),app.studyplans=response;const parts=window.location.hash.replace("#","").split("-");if(parts&&parts.length>0)for(let idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1]);break}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"view"}}])[0].done((function(response){const contexts=[];for(const ix in response)response[ix].studyplancount>0&&contexts.push(response[ix]);app.usedcontexts=contexts})).fail(_notification.default.exception)},computed:{dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},methods:{switchContext(cat){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",cat.context_id),window.location.search=params.toString()},closeStudyplan(){app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,window.location.hash=""},selectStudyplan(studyplan,studentid){app.loadingstudyplan=!0,app.activestudyplan=null,app.associatedstudents=[],app.selectedstudent=null,app.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),app.displayedstudyplan=app.activestudyplan,app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id,(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated",args:{studyplan_id:studyplan.id}}])[0].done((function(response){if(app.associatedstudents=response,studentid)for(const student of app.associatedstudents)if(student.id==studentid){app.showStudentView(student);break}})).fail(_notification.default.exception)})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){app.selectedstudent=student,app.studentstudyplan=null,app.loadingstudyplan=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_get_user_studyplan",args:{userid:student.id,studyplanid:app.activestudyplan.id}}])[0].done((function(response){app.studentstudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id+"-"+student.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showOverview(){app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,window.location.hash=app.activestudyplan.id}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);new _debugger.default("treestudyplanviewer");let strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); //# sourceMappingURL=page-view-plan.min.js.map \ No newline at end of file diff --git a/amd/build/page-view-plan.min.js.map b/amd/build/page-view-plan.min.js.map index 45453b1..0808783 100644 --- a/amd/build/page-view-plan.min.js.map +++ b/amd/build/page-view-plan.min.js.map @@ -1 +1 @@ -{"version":3,"file":"page-view-plan.min.js","sources":["../src/page-view-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 {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\nimport TSComponents from './treestudyplan-components';\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplanviewer\");\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\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 */\nexport function init(contextid,categoryid) {\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 const in_systemcontext = (contextid <= 1);\n\n let app = new Vue({\n el: '#root',\n data: {\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.studyplan,\n toolbox: {\n right: true,\n },\n usedcontexts: [],\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: {context_id: contextid}\n }])[0].done(function(response){\n const timingval = { present: 0, past: 1, future: 2};\n response.sort((a,b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n\n const t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by name if timing is equal\n return a.name.localeCompare(b.name);\n }\n else {\n return t;\n }\n });\n app.studyplans = response;\n // load studyplan from hash if applicable\n const hash = window.location.hash.replace('#','');\n const parts = hash.split(\"-\");\n\n if(!!parts && parts.length > 0){\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == parts[0]){\n app.selectStudyplan(app.studyplans[idx],parts[1]);\n break;\n }\n }\n }\n }).fail(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_used_categories',\n args: { operation: 'view'}\n }])[0].done(function(response){\n const contexts = [];\n for(const ix in response){\n if(response[ix].studyplancount >0){\n contexts.push(response[ix]);\n }\n }\n app.usedcontexts = contexts;\n }).fail(notification.exception);\n },\n computed: {\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 methods: {\n switchContext(ctx){\n const params = new URLSearchParams(location.search);\n params.set('categoryid', ctx.id);\n window.location.search = params.toString();\n\n },\n closeStudyplan() {\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n window.location.hash = '';\n },\n\n selectStudyplan(studyplan,studentid){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.selectedstudent = null;\n app.studentstudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplan.id}\n }])[0].done(function(response){\n app.activestudyplan = ProcessStudyplan(response,true);\n app.displayedstudyplan = app.activestudyplan;\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n call([{\n methodname: 'local_treestudyplan_all_associated',\n args: { studyplan_id: studyplan.id}\n }])[0].done(function(response){\n app.associatedstudents = response;\n if(studentid){\n for(const student of app.associatedstudents){\n if(student.id == studentid){\n app.showStudentView(student);\n break;\n }\n }\n }\n }).fail(notification.exception);\n\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student){\n app.selectedstudent = student;\n app.studentstudyplan = null;\n app.loadingstudyplan = true;\n call([{\n methodname: 'local_treestudyplan_get_user_studyplan',\n args: { userid: student.id, studyplanid: app.activestudyplan.id}\n }])[0].done(function(response){\n app.studentstudyplan = ProcessStudyplan(response,false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n\n\n },\n showOverview(){\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n window.location.hash = app.activestudyplan.id;\n }\n\n },\n });\n}\n"],"names":["contextid","categoryid","undefined","Number","isInteger","app","Vue","el","data","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","studyplan","toolbox","right","usedcontexts","methodname","args","context_id","done","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","fail","notification","exception","operation","contexts","ix","studyplancount","push","computed","dropdown_title","this","studyplan_select_placeholder","methods","switchContext","ctx","params","URLSearchParams","search","set","toString","closeStudyplan","studentid","studyplan_id","student","showStudentView","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"kqBA2CqBA,UAAUC,YAE4DD,eAApFE,IAAcF,YAAcG,OAAOC,UAAUD,OAAOH,aAAeA,UAAY,EAAiB,EAChFG,OAAOH,WAEnBC,gBADJC,IAAcD,YAAeE,OAAOC,UAAUD,OAAOF,aAC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SAASC,KAAOrC,IAAIK,gBAAgBqC,GAAK,IAAMyB,QAAQzB,MAC/DE,MAAK,SAASyB,6BACAvB,UAAUuB,OACvBrE,IAAIS,kBAAmB,MAK/B+D,eACIxE,IAAIO,gBAAkB,KACtBP,IAAIQ,iBAAmB,KACvBR,IAAII,mBAAqBJ,IAAIK,gBAC7B8B,OAAOC,SAASC,KAAOrC,IAAIK,gBAAgBqC,+bArLvD+B,IAAIC,8CAGJD,IAAIE,oCAGJF,IAAIG,iCAEJH,IAAII,uBAGI,IAAIC,kBAAS,2BAErBlE,SAAU,8BAAa,CACvBC,UAAW,CACP0C,6BAA8B"} \ No newline at end of file +{"version":3,"file":"page-view-plan.min.js","sources":["../src/page-view-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 {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\nimport TSComponents from './treestudyplan-components';\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplanviewer\");\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\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 */\nexport function init(contextid,categoryid) {\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 const in_systemcontext = (contextid <= 1);\n\n let app = new Vue({\n el: '#root',\n data: {\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.studyplan,\n toolbox: {\n right: true,\n },\n usedcontexts: [],\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: {context_id: contextid}\n }])[0].done(function(response){\n const timingval = { present: 0, past: 1, future: 2};\n response.sort((a,b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n\n const t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by name if timing is equal\n return a.name.localeCompare(b.name);\n }\n else {\n return t;\n }\n });\n app.studyplans = response;\n // load studyplan from hash if applicable\n const hash = window.location.hash.replace('#','');\n const parts = hash.split(\"-\");\n\n if(!!parts && parts.length > 0){\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == parts[0]){\n app.selectStudyplan(app.studyplans[idx],parts[1]);\n break;\n }\n }\n }\n }).fail(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_used_categories',\n args: { operation: 'view'}\n }])[0].done(function(response){\n const contexts = [];\n for(const ix in response){\n if(response[ix].studyplancount >0){\n contexts.push(response[ix]);\n }\n }\n app.usedcontexts = contexts;\n }).fail(notification.exception);\n },\n computed: {\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 methods: {\n switchContext(cat){\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set('contextid', cat.context_id);\n window.location.search = params.toString();\n },\n closeStudyplan() {\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n window.location.hash = '';\n },\n\n selectStudyplan(studyplan,studentid){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.selectedstudent = null;\n app.studentstudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplan.id}\n }])[0].done(function(response){\n app.activestudyplan = ProcessStudyplan(response,true);\n app.displayedstudyplan = app.activestudyplan;\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n call([{\n methodname: 'local_treestudyplan_all_associated',\n args: { studyplan_id: studyplan.id}\n }])[0].done(function(response){\n app.associatedstudents = response;\n if(studentid){\n for(const student of app.associatedstudents){\n if(student.id == studentid){\n app.showStudentView(student);\n break;\n }\n }\n }\n }).fail(notification.exception);\n\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student){\n app.selectedstudent = student;\n app.studentstudyplan = null;\n app.loadingstudyplan = true;\n call([{\n methodname: 'local_treestudyplan_get_user_studyplan',\n args: { userid: student.id, studyplanid: app.activestudyplan.id}\n }])[0].done(function(response){\n app.studentstudyplan = ProcessStudyplan(response,false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n\n\n },\n showOverview(){\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n window.location.hash = app.activestudyplan.id;\n }\n\n },\n });\n}\n"],"names":["contextid","categoryid","undefined","Number","isInteger","app","Vue","el","data","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","studyplan","toolbox","right","usedcontexts","methodname","args","context_id","done","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","fail","notification","exception","operation","contexts","ix","studyplancount","push","computed","dropdown_title","this","studyplan_select_placeholder","methods","switchContext","cat","params","URLSearchParams","search","delete","set","toString","closeStudyplan","studentid","studyplan_id","student","showStudentView","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"kqBA2CqBA,UAAUC,YAE4DD,eAApFE,IAAcF,YAAcG,OAAOC,UAAUD,OAAOH,aAAeA,UAAY,EAAiB,EAChFG,OAAOH,WAEnBC,gBADJC,IAAcD,YAAeE,OAAOC,UAAUD,OAAOF,aACpCE,OAAOF,YADyD,MAKhFI,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,mBAAoB,KACpBC,gBAAiB,KACjBC,mBAAoB,GACpBC,gBAAiB,KACjBC,iBAAkB,KAClBC,kBAAkB,EAClBC,WAAY,GACZC,KAAMC,QAAQC,UACdC,QAAS,CACLC,OAAO,GAEXC,aAAc,mCAGT,CAAC,CACFC,WAAY,sCACZC,KAAM,CAACC,WAAYxB,cACnB,GAAGyB,MAAK,SAASC,gBACXC,UAAY,CAAEC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GACjDJ,SAASK,MAAK,CAACC,EAAEC,WACPC,SAAU,+BAAgBF,GAC1BG,SAAU,+BAAgBF,GAE1BG,EAAIT,UAAUO,SAAWP,UAAUQ,gBACjC,GAALC,EAEQJ,EAAEK,KAAKC,cAAcL,EAAEI,MAGvBD,KAGf/B,IAAIU,WAAaW,eAGXa,MADOC,OAAOC,SAASC,KAAKC,QAAQ,IAAI,IAC3BC,MAAM,QAEpBL,OAASA,MAAMM,OAAS,MACrB,IAAIC,OAAOzC,IAAIU,cACZV,IAAIU,WAAW+B,KAAKC,IAAMR,MAAM,GAAG,CAClClC,IAAI2C,gBAAgB3C,IAAIU,WAAW+B,KAAKP,MAAM,cAK3DU,KAAKC,sBAAaC,0BAChB,CAAC,CAC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mBAKjCxB,KAAKC,sBAAaC,cAEtBF,MAAK,SAAS0B,6BACAxB,UAAUwB,OACvBtE,IAAIS,kBAAmB,MAG/B4D,gBAAgBD,SACZpE,IAAIO,gBAAkB6D,QACtBpE,IAAIQ,iBAAmB,KACvBR,IAAIS,kBAAmB,iBAClB,CAAC,CACFQ,WAAY,yCACZC,KAAM,CAAEqD,OAAQH,QAAQ1B,GAAI8B,YAAaxE,IAAIK,gBAAgBqC,OAC7D,GAAGtB,MAAK,SAASC,UACjBrB,IAAIQ,kBAAmB,wCAAiBa,UAAS,GACjDrB,IAAII,mBAAqBJ,IAAIQ,iBAC7BR,IAAIS,kBAAmB,EACvB0B,OAAOC,SAASC,KAAOrC,IAAIK,gBAAgBqC,GAAK,IAAM0B,QAAQ1B,MAC/DE,MAAK,SAAS0B,6BACAxB,UAAUwB,OACvBtE,IAAIS,kBAAmB,MAK/BgE,eACIzE,IAAIO,gBAAkB,KACtBP,IAAIQ,iBAAmB,KACvBR,IAAII,mBAAqBJ,IAAIK,gBAC7B8B,OAAOC,SAASC,KAAOrC,IAAIK,gBAAgBqC,+bArLvDgC,IAAIC,8CAGJD,IAAIE,oCAGJF,IAAIG,iCAEJH,IAAII,uBAGI,IAAIC,kBAAS,2BAErBnE,SAAU,8BAAa,CACvBC,UAAW,CACP0C,6BAA8B"} \ 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 3aa6a76..0379dfc 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","core/str","./util/string-helper","./util/date-helper","./studyplan-processor","./util/debugger","./downloader","core/edit_switch","./treestudyplan-components","./util/mform-helper"],(function(_exports,_simpleline,_ajax,_notification,_str,_stringHelper,_dateHelper,_studyplanProcessor,_debugger,_downloader,_edit_switch,_treestudyplanComponents,_mformHelper){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),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_mformHelper=_interopRequireDefault(_mformHelper);const STUDYPLAN_EDITOR_FIELDS=["name","shortname","description","idnumber","context_id","aggregation","aggregation_config"],PERIOD_EDITOR_FIELDS=["fullname","shortname","startdate","enddate"],datechanger_globals={default:!1,defaultchoice:!1,hidewarn:!1};var _default={STUDYPLAN_EDITOR_FIELDS:STUDYPLAN_EDITOR_FIELDS,install(Vue){Vue.use(_treestudyplanComponents.default),Vue.use(_mformHelper.default);let debug=new _debugger.default("treestudyplan-editor");function isVisible(elem){return!!(elem.offsetWidth||elem.offsetHeight||elem.getClientRects().length)}const ItemEventBus=new Vue;document.addEventListener(_edit_switch.eventTypes.editModeSet,(e=>{e.preventDefault(),ItemEventBus.$emit("editModeSet",e.detail.editMode)}));let string_keys=(0,_stringHelper.load_stringkeys)({conditions:[{value:"ALL",textkey:"condition_all"},{value:"ANY",textkey:"condition_any"}]}),strings=(0,_stringHelper.load_strings)({studyplan_text:{studyline_editmode:"studyline_editmode",toolbox_toggle:"toolbox_toggle",editmode_modules_hidden:"editmode_modules_hidden",studyline_add:"studyline_add",add$core:"add$core",edit$core:"edit$core",studyline_name:"studyline_name",studyline_name_ph:"studyline_name_ph",studyline_shortname:"studyline_shortname",studyline_shortname_ph:"studyline_shortname_ph",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"},studyplan_advanced:{advanced_tools:"advanced_tools",confirm_cancel:"confirm_cancel",confirm_ok:"confirm_ok",success$core:"success$core",error$core:"failed$core",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"},studyplan_edit:{studyplan_edit:"studyplan_edit",studyplan_add:"studyplan_add",studyplanpage_add:"studyplanpage_add",studyplanpage_edit:"studyplanpage_edit"},period_edit:{edit:"period_edit",fullname:"studyplan_name",shortname:"studyplan_shortname",startdate:"studyplan_startdate",enddate:"studyplan_enddate"},course_timing:{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"},studyplan_associate:{associations:"associations",associated_cohorts:"associated_cohorts",associated_users:"associated_users",associate_cohorts:"associate_cohorts",associate_users:"associate_users",add_association:"add_association",delete_association:"delete_association",associations_empty:"associations_empty",associations_search:"associations_search",cohorts:"cohorts",users:"users",selected:"selected",name:"name",context:"context"},item_text:{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"},item_course_text:{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"},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"}});Vue.component("t-studyplan-advanced",{props:{value:{type:Object,default:()=>null},selectedpage:{type:Object,default:()=>null}},data:()=>({force_scales:{selected_scale:null,result:[]},text:strings.studyplan_advanced}),created(){},mounted(){},updated(){},computed:{scales(){return[{id:null,disabled:!0,name:this.text.advanced_pick_scale}].concat(this.value.advanced.force_scales.scales)}},methods:{force_scales_start(){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.force_scales.selected_scale}}])[0].done((function(response){self.force_scales.result=response})).fail(_notification.default.exception)}))},export_page(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].done((function(response){(0,_downloader.download)(self.value.shortname+".page."+format,response.content,response.format)})).fail(_notification.default.exception)},export_plan(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:this.value.id,format:"json"}}])[0].done((function(response){(0,_downloader.download)(self.value.shortname+".plan.json",response.content,response.format)})).fail(_notification.default.exception)},bulk_course_timing(){(0,_ajax.call)([{methodname:"local_treestudyplan_bulk_course_timing",args:{page_id:this.selectedpage.id}}])[0].done((function(response){response.success?location.reload():(this.$bvModal.msgBoxOk(response.msg,{title:"Could not set bulk course timing"}),debug.error("Could not set bulk course timing: ",response.msg))})).fail(_notification.default.exception)},import_studylines(){(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].done((function(response){response.success?location.reload():(this.$bvModal.msgBoxOk(response.msg,{title:"Import failed"}),debug.error("Import failed: ",response.msg))})).fail(_notification.default.exception)}),"application/json")},import_pages(){(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].done((function(response){response.success?location.reload():(this.$bvModal.msgBoxOk(response.msg,{title:"Import failed"}),debug.error("Import failed: ",response.msg))})).fail(_notification.default.exception)}),"application/json")},purge_studyplan(){(0,_ajax.call)([{methodname:"local_treestudyplan_delete_studyplan",args:{id:this.value.id,force:!0}}])[0].done((function(response){response.success?location.reload():(this.$bvModal.msgBoxOk(response.msg,{title:"Could not delete plan "}),debug.error("Could not delete plan: ",response.msg))})).fail(_notification.default.exception)},purge_studyplanpage(){this.selectedpage&&(0,_ajax.call)([{methodname:"local_treestudyplan_delete_studyplanpage",args:{id:this.selectedpage.id,force:!0}}])[0].done((function(response){response.success?location.reload():(this.$bvModal.msgBoxOk(response.msg,{title:"Could not delete page"}),debug.error("Could not delete page: ",response.msg))})).fail(_notification.default.exception)},cascade_cohortsync(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_cascade_cohortsync",args:{studyplan_id:this.value.id}}])[0].done((function(response){self.$bvModal.msgBoxOk(response.success?self.text.success$core:self.text.error$core,{title:self.text.advanced_cascade_cohortsync})})).fail(_notification.default.exception)},modal_close(){this.force_scales.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.studyplan_edit}),computed:{},methods:{planSaved(updatedplan){const self=this;if(debug.info("Got new plan data",updatedplan),"create"==self.mode)self.$emit("created",updatedplan);else{const moved_from=self.value.context_id,moved_to=updatedplan.context_id,moved=moved_from!=moved_to;updatedplan.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,updatedplan,STUDYPLAN_EDITOR_FIELDS),self.$emit("input",self.value),moved&&self.$emit("moved",self.value,moved_from,moved_to))}}},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.studyplan_edit}),computed:{},methods:{planSaved(updatedpage){const self=this;if(debug.info("Got new page data",updatedpage),"create"==self.mode)self.$emit("created",updatedpage);else{const page=(0,_studyplanProcessor.ProcessStudyplanPage)(updatedpage);debug.info("studyplan page processed"),self.$emit("input",page)}}},template:'\n \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:[]},loading:{cohorts:!1,users:!1},search:{users:[],cohorts:[]},selected:{search:{users:[],cohorts:[]},associated:{users:[],cohorts:[]}},text:strings.studyplan_associate}),created(){},mounted(){},updated(){},methods:{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].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(searchtext){const 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(){const self=this;let requests=[];const associated=self.association.cohorts,search=self.search.cohorts,searchselected=self.selected.search.cohorts;for(const i in searchselected){const 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)}})}(0,_ajax.call)(requests)},cohortDisassociate(){const self=this;let requests=[];const associatedselected=self.selected.associated.cohorts,associated=self.association.cohorts,search=self.search.cohorts;for(const i in associatedselected){const 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)}})}(0,_ajax.call)(requests)},searchUsers(searchtext){const 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(){const self=this;let requests=[];const associated=self.association.users,search=self.search.users,searchselected=self.selected.search.users;for(const i in searchselected){const 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)}})}(0,_ajax.call)(requests)},userDisassociate(){const self=this;let requests=[];const associated=self.association.users,associatedselected=self.selected.associated.users,search=self.search.users;for(const i in associatedselected){const 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)}})}(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:()=>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.period_edit}),created(){},mounted(){},updated(){},computed:{},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_treestudyplan_edit_period",args:args}])[0].done((function(response){(0,_studyplanProcessor.objCopy)(self.value,response,PERIOD_EDITOR_FIELDS),self.$emit("input",self.value),self.$emit("edited",self.value)})).fail(_notification.default.exception)},refresh(){const self=this;(0,_ajax.call)([{methodname:"local_treestudyplan_get_period",args:{id:this.value.id}}])[0].done((function(response){(0,_studyplanProcessor.objCopy)(self.value,response,PERIOD_EDITOR_FIELDS),self.$emit("input",self.value)})).fail(_notification.default.exception)},add_day:(date,days)=>(void 0===days&&(days=1),(0,_dateHelper.add_days)(date,days)),sub_day:(date,days)=>(void 0===days&&(days=1),(0,_dateHelper.add_days)(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","index","initeditmode"],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"},page:{id:-1,name:"",shortname:""}},edit:{toolbox_shown:!1,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:{}},selectedpageindex:0,emptyline:{id:-1,name:"",shortname:"",color:"#FF0000",filterslots:[{}],courseslots:[{}]}}),created(){const self=this;ItemEventBus.$on("editModeSet",this.onMoodleEditModeChanged),ItemEventBus.$on("coursechange",(()=>{self.$emit("pagechanged",this.selectedpage)}))},mounted(){this.edit.studyline.editmode=this.initeditmode,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]}},methods:{onMoodleEditModeChanged(mode){this.edit.studyline.editmode=mode},columns:page=>1+2*page.periods,columns_stylerule(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]){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;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)][0];prev&&prev.refresh();const next=this.$refs["periodeditor-"+(pi.period+1)][0];next&&next.refresh()},add_day:(date,days)=>(void 0===days&&(days=1),(0,_dateHelper.add_days)(date,days)),sub_day:(date,days)=>(void 0===days&&(days=1),(0,_dateHelper.add_days)(date,0-days)),toolbox_switched(event){this.$emit("toggletoolbox",event)},pagecreated(page){this.value.pages.push(page)},selectedpageChanged(newTabIndex,prevTabIndex){const page=this.value.pages[newTabIndex];this.$emit("pagechanged",page)}},template:'\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$core}}\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