From 88744c2b668fa669b535e989a70e3421ec9bf25b Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Mon, 25 Mar 2024 23:42:40 +0100 Subject: [PATCH] fixed issues with Moodle 3.11 compatibility --- amd/build/modedit-modal.min.js.map | 2 +- amd/build/page-edit-plan.min.js | 2 +- amd/build/page-edit-plan.min.js.map | 2 +- amd/build/util/mform-helper.min.js.map | 2 +- amd/src/modedit-modal.js | 15 +++++++++++++++ amd/src/page-edit-plan.js | 13 ++++++++++++- amd/src/util/mform-helper.js | 15 +++++++++++++++ 7 files changed, 46 insertions(+), 5 deletions(-) diff --git a/amd/build/modedit-modal.min.js.map b/amd/build/modedit-modal.min.js.map index 4607e75..d272a2a 100644 --- a/amd/build/modedit-modal.min.js.map +++ b/amd/build/modedit-modal.min.js.map @@ -1 +1 @@ -{"version":3,"file":"modedit-modal.min.js","sources":["../src/modedit-modal.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint-disable no-trailing-spaces */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n\nimport {loadFragment} from 'core/fragment';\nimport {load_strings} from './util/string-helper';\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\nimport {replaceNodeContents} from 'core/templates';\n//import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only\n//import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only\n\nexport default {\n install(Vue/*,options*/){\n\n let strings = load_strings({\n editmod: {\n save$core: \"save$core\",\n cancel$core: \"cancel$core\",\n }\n });\n\n Vue.component('s-edit-mod', {\n props: {\n cmid: {\n type: Number,\n },\n coursectxid:{\n type: Number,\n },\n title: {\n type: String,\n default: \"\",\n },\n genericonly: {\n type: Boolean,\n default: false,\n }\n },\n data() {\n return {\n content: \"\",\n text: strings.editmod,\n };\n },\n computed: {\n },\n methods: {\n openForm(){\n const self = this;\n self.$refs[\"editormodal\"].show();\n },\n onShown(){\n const self = this;\n let params = {cmid: this.cmid};\n console.info(\"Loading form\");\n loadFragment('local_treestudyplan', 'mod_edit_form', this.coursectxid, params).then((html,js) =>{\n replaceNodeContents(self.$refs[\"content\"], html, js);\n }).catch(notification.exception);\n\n },\n onSave(){\n const self = this;\n let form = this.$refs[\"content\"].getElementsByTagName(\"form\")[0];\n\n // markFormSubmitted(form); // Moodle 4.00+ only\n // We call this, so other modules can update the form with the latest state.\n form.dispatchEvent(new Event(\"save-form-state\"));\n // Tell all form fields we are about to submit the form.\n // notifyFormSubmittedByJavascript(form); // Moodle 4.00+ only\n\n const formdata = new FormData(form);\n const data = new URLSearchParams(formdata).toString();\n //const formdata = new FormData(form);\n //const data = {};\n //formdata.forEach((value, key) => (data[key] = value));\n\n call([{\n methodname: 'local_treestudyplan_submit_cm_editform',\n args: {cmid: this.cmid, formdata: data}\n }])[0].then(()=>{\n self.$emit(\"saved\",formdata);\n }).catch(notification.exception);\n\n }\n },\n template: `\n \n
\n \n `,\n });\n }\n};\n\n"],"names":["install","Vue","strings","editmod","save$core","cancel$core","component","props","cmid","type","Number","coursectxid","title","String","default","genericonly","Boolean","data","content","text","computed","methods","openForm","this","$refs","show","onShown","self","params","console","info","then","html","js","catch","notification","exception","onSave","form","getElementsByTagName","dispatchEvent","Event","formdata","FormData","URLSearchParams","toString","methodname","args","$emit","template"],"mappings":"mYAce,CACXA,QAAQC,SAEAC,SAAU,8BAAa,CACvBC,QAAS,CACLC,UAAW,YACXC,YAAa,iBAIrBJ,IAAIK,UAAU,aAAc,CACxBC,MAAO,CACHC,KAAM,CACFC,KAAMC,QAEVC,YAAY,CACRF,KAAMC,QAEVE,MAAO,CACHH,KAAMI,OACNC,QAAS,IAEbC,YAAa,CACTN,KAAMO,QACNF,SAAS,IAGjBG,KAAI,KACO,CACHC,QAAS,GACTC,KAAMjB,QAAQC,UAGtBiB,SAAU,GAEVC,QAAS,CACLC,WACiBC,KACRC,MAAL,YAA0BC,QAE9BC,gBACUC,KAAOJ,SACTK,OAAS,CAACpB,KAAMe,KAAKf,MACzBqB,QAAQC,KAAK,2CACA,sBAAuB,gBAAiBP,KAAKZ,YAAaiB,QAAQG,MAAK,CAACC,KAAKC,yCAClEN,KAAKH,MAAL,QAAuBQ,KAAMC,OAClDC,MAAMC,sBAAaC,YAG1BC,eACUV,KAAOJ,SACTe,KAAOf,KAAKC,MAAL,QAAsBe,qBAAqB,QAAQ,GAI9DD,KAAKE,cAAc,IAAIC,MAAM,0BAIvBC,SAAW,IAAIC,SAASL,MACxBrB,KAAO,IAAI2B,gBAAgBF,UAAUG,0BAKtC,CAAC,CACFC,WAAY,yCACZC,KAAM,CAACvC,KAAMe,KAAKf,KAAMkC,SAAUzB,SAClC,GAAGc,MAAK,KACRJ,KAAKqB,MAAM,QAAQN,aACpBR,MAAMC,sBAAaC,aAI9Ba,SAAW"} \ No newline at end of file +{"version":3,"file":"modedit-modal.min.js","sources":["../src/modedit-modal.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint-disable no-trailing-spaces */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n\nimport {loadFragment} from 'core/fragment';\nimport {load_strings} from './util/string-helper';\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\nimport {replaceNodeContents} from 'core/templates';\n//import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only\n//import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only\n\n/* Moodle 3.11 safe import for when needed\nlet markFormSubmitted = () => {};\nlet notifyFormSubmittedByJavascript = () => {};\n\nimport('core_form/changechecker').then((ns) => {\n debug.info(ns);\n if(ns.markFormSubmitted) {\n markFormSubmitted = ns.markFormSubmitted;\n }\n if(ns.notifyFormSubmittedByJavascript) {\n notifyFormSubmittedByJavascript = ns.notifyFormSubmittedByJavascript;\n }\n}).catch(()=>{});\n*/\n\nexport default {\n install(Vue/*,options*/){\n\n let strings = load_strings({\n editmod: {\n save$core: \"save$core\",\n cancel$core: \"cancel$core\",\n }\n });\n\n Vue.component('s-edit-mod', {\n props: {\n cmid: {\n type: Number,\n },\n coursectxid:{\n type: Number,\n },\n title: {\n type: String,\n default: \"\",\n },\n genericonly: {\n type: Boolean,\n default: false,\n }\n },\n data() {\n return {\n content: \"\",\n text: strings.editmod,\n };\n },\n computed: {\n },\n methods: {\n openForm(){\n const self = this;\n self.$refs[\"editormodal\"].show();\n },\n onShown(){\n const self = this;\n let params = {cmid: this.cmid};\n console.info(\"Loading form\");\n loadFragment('local_treestudyplan', 'mod_edit_form', this.coursectxid, params).then((html,js) =>{\n replaceNodeContents(self.$refs[\"content\"], html, js);\n }).catch(notification.exception);\n\n },\n onSave(){\n const self = this;\n let form = this.$refs[\"content\"].getElementsByTagName(\"form\")[0];\n\n // markFormSubmitted(form); // Moodle 4.00+ only\n // We call this, so other modules can update the form with the latest state.\n form.dispatchEvent(new Event(\"save-form-state\"));\n // Tell all form fields we are about to submit the form.\n // notifyFormSubmittedByJavascript(form); // Moodle 4.00+ only\n\n const formdata = new FormData(form);\n const data = new URLSearchParams(formdata).toString();\n //const formdata = new FormData(form);\n //const data = {};\n //formdata.forEach((value, key) => (data[key] = value));\n\n call([{\n methodname: 'local_treestudyplan_submit_cm_editform',\n args: {cmid: this.cmid, formdata: data}\n }])[0].then(()=>{\n self.$emit(\"saved\",formdata);\n }).catch(notification.exception);\n\n }\n },\n template: `\n \n
\n \n `,\n });\n }\n};\n\n"],"names":["install","Vue","strings","editmod","save$core","cancel$core","component","props","cmid","type","Number","coursectxid","title","String","default","genericonly","Boolean","data","content","text","computed","methods","openForm","this","$refs","show","onShown","self","params","console","info","then","html","js","catch","notification","exception","onSave","form","getElementsByTagName","dispatchEvent","Event","formdata","FormData","URLSearchParams","toString","methodname","args","$emit","template"],"mappings":"mYA6Be,CACXA,QAAQC,SAEAC,SAAU,8BAAa,CACvBC,QAAS,CACLC,UAAW,YACXC,YAAa,iBAIrBJ,IAAIK,UAAU,aAAc,CACxBC,MAAO,CACHC,KAAM,CACFC,KAAMC,QAEVC,YAAY,CACRF,KAAMC,QAEVE,MAAO,CACHH,KAAMI,OACNC,QAAS,IAEbC,YAAa,CACTN,KAAMO,QACNF,SAAS,IAGjBG,KAAI,KACO,CACHC,QAAS,GACTC,KAAMjB,QAAQC,UAGtBiB,SAAU,GAEVC,QAAS,CACLC,WACiBC,KACRC,MAAL,YAA0BC,QAE9BC,gBACUC,KAAOJ,SACTK,OAAS,CAACpB,KAAMe,KAAKf,MACzBqB,QAAQC,KAAK,2CACA,sBAAuB,gBAAiBP,KAAKZ,YAAaiB,QAAQG,MAAK,CAACC,KAAKC,yCAClEN,KAAKH,MAAL,QAAuBQ,KAAMC,OAClDC,MAAMC,sBAAaC,YAG1BC,eACUV,KAAOJ,SACTe,KAAOf,KAAKC,MAAL,QAAsBe,qBAAqB,QAAQ,GAI9DD,KAAKE,cAAc,IAAIC,MAAM,0BAIvBC,SAAW,IAAIC,SAASL,MACxBrB,KAAO,IAAI2B,gBAAgBF,UAAUG,0BAKtC,CAAC,CACFC,WAAY,yCACZC,KAAM,CAACvC,KAAMe,KAAKf,KAAMkC,SAAUzB,SAClC,GAAGc,MAAK,KACRJ,KAAKqB,MAAM,QAAQN,aACpBR,MAAMC,sBAAaC,aAI9Ba,SAAW"} \ No newline at end of file diff --git a/amd/build/page-edit-plan.min.js b/amd/build/page-edit-plan.min.js index bb49554..154fe93 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","core_form/changechecker","./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"],(function(_exports,_str,_ajax,_notification,_changechecker,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_portalVue,_bootstrapVue){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"}: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:[],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()},computed:{dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},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){const id=hash;app.selectStudyplan(id)}})).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)},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),(0,_changechecker.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),_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);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"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_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:[],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()},computed:{dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},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){const id=hash;app.selectStudyplan(id)}})).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)},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),_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(_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"}})})); //# 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 c947ecb..77e5029 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';\nimport {resetAllFormDirtyStates} from 'core_form/changechecker';\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';\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\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 \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\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 },\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 },\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 const id = hash;\n app.selectStudyplan(id);\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 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","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","initialize","computed","dropdown_title","this","studyplan_select_placeholder","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","refcontext_id","closeStudyplan","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","setTimeout","toString","onStudyPlanCreated","newstudyplan","pathname","push","switchContext","ctxid","href","studyplanid","error","import_studyplan","self","filename","content","format","success","msg","export_plan","includes","studyplan_id","use","EditorComponents","TSComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"4vBAkDqBA,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,m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AIgB,gBAAgBY,MAC5C+B,OAAM,SAAS0B,6BACDxB,UAAUwB,OACvBrF,IAAIkB,kBAAmB,MAG/BoE,yBACUC,KAAOrD,6BACN,CAACsD,SAASC,0BACR,CAAC,CACFpD,WAAY,kCACZC,KAAM,CACFmD,QAASA,QACTC,OAAQ,mBACRnD,WAAYlD,cAEhB,GAAGmD,MAAK,SAASC,UACdA,SAASkD,QACRJ,KAAKxD,aAELpC,MAAM0F,MAAM,kBAAkB5C,SAASmD,QAG5CjC,MAAMC,sBAAaC,aACvB,qBAEPgC,YAAY1B,KAAKuB,QAEAlG,MAAVkG,QAAwB,CAAC,OAAO,OAAOI,SAASJ,UAC/CA,OAAS,uBAER,CAAC,CACErD,WAAY,kCACZC,KAAM,CACFyD,aAAc5B,KAAKvC,GACnB8D,OAAQA,WAEZ,GAAGlD,MAAK,SAASC,mCAER0B,KAAK5D,UAAU,QAAQkC,SAASgD,QAAQhD,SAASiD,WAC3D/B,MAAMC,sBAAaC,6cApPtCmC,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,oCASJH,IAAII,iCAEJJ,IAAIK,6BAGF1G,MAAQ,IAAI2G,kBAAS,qBAEvBjF,SAAU,8BAAa,CACvBhB,UAAW,CACP8B,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\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';\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\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 },\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\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 },\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 },\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 const id = hash;\n app.selectStudyplan(id);\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 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","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","initialize","computed","dropdown_title","this","studyplan_select_placeholder","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","refcontext_id","closeStudyplan","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","PortalVue","BootstrapVue","Debugger","ns"],"mappings":"ioBA6DqBA,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,GAEZC,KAAMC,QAAQhB,UACdiB,aAAc,IAElBC,eACSC,MAAMC,IAAI,oBAAoBpB,YAE5BL,IAAIgB,iBAAmBX,YACtBL,IAAIgB,gBAAkB,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D,WAAY,kCACZC,KAAM,CACF0D,aAAc7B,KAAKvC,GACnB+D,OAAQA,WAEZ,GAAGnD,MAAK,SAASC,mCAER0B,KAAK5D,UAAU,QAAQkC,SAASiD,QAAQjD,SAASkD,WAC3DhC,MAAMC,sBAAaC,irBA9PtCoC,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,oCASJH,IAAII,iCAEJJ,IAAIK,6BAGF3G,MAAQ,IAAI4G,kBAAS,qBAEvBxB,wBAA0B,+nBACIvC,MAAMgE,KACpC7G,MAAMC,KAAK4G,IACRA,GAAGzB,0BACFA,wBAA0ByB,GAAGzB,4BAElCpB,OAAM,aAILtC,SAAU,8BAAa,CACvBhB,UAAW,CACP8B,6BAA8B"} \ No newline at end of file diff --git a/amd/build/util/mform-helper.min.js.map b/amd/build/util/mform-helper.min.js.map index 8ead82c..c4516bb 100644 --- a/amd/build/util/mform-helper.min.js.map +++ b/amd/build/util/mform-helper.min.js.map @@ -1 +1 @@ -{"version":3,"file":"mform-helper.min.js","sources":["../../src/util/mform-helper.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint no-bitwise: \"off\"*/\n/*eslint-disable no-trailing-spaces*/\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n\nimport {call} from 'core/ajax';\nimport {processCollectedJavascript} from 'core/fragment';\nimport {replaceNodeContents} from 'core/templates';\nimport notification from 'core/notification';\nimport {load_strings} from './string-helper';\nimport Debugger from './debugger';\n//import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only\n//import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only\n\n/**\n * Create a random UUID in both secure and insecure contexts\n * @returns UUID\n */\nfunction create_uuid() {\n if (crypto.randomUUID !== undefined ) {\n return crypto.randomUUID();\n } else {\n return \"10000000-1000-4000-8000-100000000000\".replace(/[018]/g, c =>\n (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)\n );\n }\n}\n\nexport default {\n install(Vue/*,options*/){\n let debug = new Debugger(\"treestudyplan-mform-helper\");\n let strings = load_strings({\n editmod: {\n save$core: \"save$core\",\n cancel$core: \"cancel$core\",\n }\n });\n\n Vue.component('mform', {\n props: {\n name: {\n type: String,\n },\n params: {\n type: Object,\n },\n title: {\n type: String,\n default: \"\",\n },\n variant: {\n type: String,\n default: \"primary\",\n },\n type: {\n type: String,\n default: \"link\",\n }\n },\n data() {\n return {\n content: \"\",\n loading: true,\n uuid: create_uuid(),\n text: strings,\n submitok: false,\n observer: null,\n inputs: [],\n };\n },\n computed: {\n },\n methods: {\n openForm() {\n const self = this;\n self.$refs[\"editormodal\"].show();\n },\n onShown() {\n const self = this;\n debug.info(`Loading form \"${self.name}\" with params`,self.params);\n self.loading = false;\n call([{\n methodname: 'local_treestudyplan_get_mform',\n args: {formname: self.name, params: JSON.stringify(self.params)}\n }])[0].then((data)=>{\n const html = data.html;\n self.loading = false;\n // Process the collected javascript;\n const js = processCollectedJavascript(data.javascript);\n replaceNodeContents(self.$refs[\"content\"], html, js);\n self.initListenChanges();\n }).catch(notification.exception);\n\n },\n onSave() {\n const self = this;\n let form = this.$refs[\"content\"].getElementsByTagName(\"form\")[0];\n\n // markFormSubmitted(form); // Moodle 4.00+ only\n // We call this, so other modules can update the form with the latest state.\n form.dispatchEvent(new Event(\"save-form-state\"));\n // Tell all form fields we are about to submit the form.\n // notifyFormSubmittedByJavascript(form); // Moodle 4.00+ only\n\n const formdata = new FormData(form);\n const data = new URLSearchParams(formdata).toString();\n\n if(this.checkSave()){\n call([{\n methodname: 'local_treestudyplan_submit_mform',\n args: {formname: self.name, params: JSON.stringify(self.params), formdata: data}\n }])[0].then((response)=>{\n const updatedplan = JSON.parse(response.data);\n self.$emit(\"saved\",updatedplan,formdata);\n }).catch(notification.exception);\n }\n /* No error if we cannot save, since it would just be to handle the edge case \n where someone clicks on the save button before\n an invalid input got a chance to update. */\n },\n checkSave() {\n let canSave = true;\n this.inputs.forEach(el => {\n el.focus();\n el.blur();\n if (el.classList.contains(\"is-invalid\")) {\n canSave = false;\n }\n },this);\n this.submitok = canSave;\n return canSave;\n },\n initListenChanges() {\n const content = this.$refs[\"content\"];\n this.inputs = content.querySelectorAll(\"input.form-control\");\n\n // Check if save needs to be blocked immediately. (delay call by a few ms)\n setTimeout(this.checkSave, 100);\n\n // Disconnect any existing observer.\n if(this.observer) {\n this.observer.disconnect();\n }\n // Initialize new observer and callback.\n this.observer = new MutationObserver((mutationList) => {\n for(const mix in mutationList){\n const mutation = mutationList[mix];\n if (mutation.type === 'attributes' && mutation.attributeName === 'class') {\n this.checkSave();\n }\n }\n });\n\n // Connect the observer to the form inputs.\n this.inputs.forEach(el => {\n this.observer.observe(el,{ attributes: true });\n },this);\n\n \n },\n \n },\n unmount() {\n if(this.observer) {\n this.observer.disconnect();\n }\n },\n template: `\n \n \n \n
\n \n `,\n });\n }\n};\n\n"],"names":["install","Vue","debug","Debugger","strings","editmod","save$core","cancel$core","component","props","name","type","String","params","Object","title","default","variant","data","content","loading","uuid","undefined","crypto","randomUUID","replace","c","getRandomValues","Uint8Array","toString","text","submitok","observer","inputs","computed","methods","openForm","this","$refs","show","onShown","self","info","methodname","args","formname","JSON","stringify","then","html","js","javascript","initListenChanges","catch","notification","exception","onSave","form","getElementsByTagName","dispatchEvent","Event","formdata","FormData","URLSearchParams","checkSave","response","updatedplan","parse","$emit","canSave","forEach","el","focus","blur","classList","contains","querySelectorAll","setTimeout","disconnect","MutationObserver","mutationList","mix","mutation","attributeName","observe","attributes","unmount","template"],"mappings":"+fA8Be,CACXA,QAAQC,SACAC,MAAQ,IAAIC,kBAAS,8BACrBC,SAAU,8BAAa,CACvBC,QAAS,CACLC,UAAW,YACXC,YAAa,iBAIrBN,IAAIO,UAAU,QAAS,CACnBC,MAAO,CACHC,KAAM,CACFC,KAAMC,QAEVC,OAAQ,CACJF,KAAMG,QAEVC,MAAO,CACHJ,KAAMC,OACNI,QAAS,IAEbC,QA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OAAOqC,SAAQC,KAChBA,GAAGC,QACHD,GAAGE,OACCF,GAAGG,UAAUC,SAAS,gBACtBN,SAAU,KAEhBhC,WACGN,SAAWsC,QACTA,SAEXjB,0BACUjC,QAAUkB,KAAKC,MAAL,aACXL,OAASd,QAAQyD,iBAAiB,sBAGvCC,WAAWxC,KAAK2B,UAAW,KAGxB3B,KAAKL,eACCA,SAAS8C,kBAGb9C,SAAW,IAAI+C,kBAAkBC,mBAC9B,MAAMC,OAAOD,aAAa,OACpBE,SAAWF,aAAaC,KACR,eAAlBC,SAASvE,MAAoD,UAA3BuE,SAASC,oBACtCnB,qBAMZ/B,OAAOqC,SAAQC,UACXvC,SAASoD,QAAQb,GAAG,CAAEc,YAAY,MACzChD,QAMViD,UACOjD,KAAKL,eACCA,SAAS8C,cAGtBS,SAAW"} \ No newline at end of file +{"version":3,"file":"mform-helper.min.js","sources":["../../src/util/mform-helper.js"],"sourcesContent":["/*eslint no-var: \"error\"*/\n/*eslint no-console: \"off\"*/\n/*eslint no-bitwise: \"off\"*/\n/*eslint-disable no-trailing-spaces*/\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n\nimport {call} from 'core/ajax';\nimport {processCollectedJavascript} from 'core/fragment';\nimport {replaceNodeContents} from 'core/templates';\nimport notification from 'core/notification';\nimport {load_strings} from './string-helper';\nimport Debugger from './debugger';\n//import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only\n//import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only\n\n/* Moodle 3.11 safe import for when needed\nlet markFormSubmitted = () => {};\nlet notifyFormSubmittedByJavascript = () => {};\n\nimport('core_form/changechecker').then((ns) => {\n debug.info(ns);\n if(ns.markFormSubmitted) {\n markFormSubmitted = ns.markFormSubmitted;\n }\n if(ns.notifyFormSubmittedByJavascript) {\n notifyFormSubmittedByJavascript = ns.notifyFormSubmittedByJavascript;\n }\n}).catch(()=>{});\n*/\n\n/**\n * Create a random UUID in both secure and insecure contexts\n * @returns UUID\n */\nfunction create_uuid() {\n if (crypto.randomUUID !== undefined ) {\n return crypto.randomUUID();\n } else {\n return \"10000000-1000-4000-8000-100000000000\".replace(/[018]/g, c =>\n (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)\n );\n }\n}\n\nexport default {\n install(Vue/*,options*/){\n let debug = new Debugger(\"treestudyplan-mform-helper\");\n let strings = load_strings({\n editmod: {\n save$core: \"save$core\",\n cancel$core: \"cancel$core\",\n }\n });\n\n Vue.component('mform', {\n props: {\n name: {\n type: String,\n },\n params: {\n type: Object,\n },\n title: {\n type: String,\n default: \"\",\n },\n variant: {\n type: String,\n default: \"primary\",\n },\n type: {\n type: String,\n default: \"link\",\n }\n },\n data() {\n return {\n content: \"\",\n loading: true,\n uuid: create_uuid(),\n text: strings,\n submitok: false,\n observer: null,\n inputs: [],\n };\n },\n computed: {\n },\n methods: {\n openForm() {\n const self = this;\n self.$refs[\"editormodal\"].show();\n },\n onShown() {\n const self = this;\n debug.info(`Loading form \"${self.name}\" with params`,self.params);\n self.loading = false;\n call([{\n methodname: 'local_treestudyplan_get_mform',\n args: {formname: self.name, params: JSON.stringify(self.params)}\n }])[0].then((data)=>{\n const html = data.html;\n self.loading = false;\n // Process the collected javascript;\n const js = processCollectedJavascript(data.javascript);\n replaceNodeContents(self.$refs[\"content\"], html, js);\n self.initListenChanges();\n }).catch(notification.exception);\n\n },\n onSave() {\n const self = this;\n let form = this.$refs[\"content\"].getElementsByTagName(\"form\")[0];\n\n // markFormSubmitted(form); // Moodle 4.00+ only\n // We call this, so other modules can update the form with the latest state.\n form.dispatchEvent(new Event(\"save-form-state\"));\n // Tell all form fields we are about to submit the form.\n // notifyFormSubmittedByJavascript(form); // Moodle 4.00+ only\n\n const formdata = new FormData(form);\n const data = new URLSearchParams(formdata).toString();\n\n if(this.checkSave()){\n call([{\n methodname: 'local_treestudyplan_submit_mform',\n args: {formname: self.name, params: JSON.stringify(self.params), formdata: data}\n }])[0].then((response)=>{\n const updatedplan = JSON.parse(response.data);\n self.$emit(\"saved\",updatedplan,formdata);\n }).catch(notification.exception);\n }\n /* No error if we cannot save, since it would just be to handle the edge case \n where someone clicks on the save button before\n an invalid input got a chance to update. */\n },\n checkSave() {\n let canSave = true;\n this.inputs.forEach(el => {\n el.focus();\n el.blur();\n if (el.classList.contains(\"is-invalid\")) {\n canSave = false;\n }\n },this);\n this.submitok = canSave;\n return canSave;\n },\n initListenChanges() {\n const content = this.$refs[\"content\"];\n this.inputs = content.querySelectorAll(\"input.form-control\");\n\n // Check if save needs to be blocked immediately. (delay call by a few ms)\n setTimeout(this.checkSave, 100);\n\n // Disconnect any existing observer.\n if(this.observer) {\n this.observer.disconnect();\n }\n // Initialize new observer and callback.\n this.observer = new MutationObserver((mutationList) => {\n for(const mix in mutationList){\n const mutation = mutationList[mix];\n if (mutation.type === 'attributes' && mutation.attributeName === 'class') {\n this.checkSave();\n }\n }\n });\n\n // Connect the observer to the form inputs.\n this.inputs.forEach(el => {\n this.observer.observe(el,{ attributes: true });\n },this);\n\n \n },\n \n },\n unmount() {\n if(this.observer) {\n this.observer.disconnect();\n }\n },\n template: `\n \n \n \n
\n \n `,\n });\n }\n};\n\n"],"names":["install","Vue","debug","Debugger","strings","editmod","save$core","cancel$core","component","props","name","type","String","params","Object","title","default","variant","data","content","loading","uuid","undefined","crypto","randomUUID","replace","c","getRandomValues","Uint8Array","toString","text","submitok","observer","inputs","computed","methods","openForm","this","$refs","show","onShown","self","info","methodname","args","formname","JSON","stringify","then","html","js","javascript","initListenChanges","catch","notification","exception","onSave","form","getElementsByTagName","dispatchEvent","Event","formdata","FormData","URLSearchParams","checkSave","response","updatedplan","parse","$emit","canSave","forEach","el","focus","blur","classList","contains","querySelectorAll","setTimeout","disconnect","MutationObserver","mutationList","mix","mutation","attributeName","observe","attributes","unmount","template"],"mappings":"+fA6Ce,CACXA,QAAQC,SACAC,MAAQ,IAAIC,kBAAS,8BACrBC,SAAU,8BAAa,C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UN,KAAK5B,QAASgD,SAAU3C,SAC3E,GAAG8B,MAAMiB,iBACHC,YAAcpB,KAAKqB,MAAMF,SAAS/C,MACxCuB,KAAK2B,MAAM,QAAQF,YAAYL,aAChCR,MAAMC,sBAAaC,YAM9BS,gBACQK,SAAU,cACTpC,OAAOqC,SAAQC,KAChBA,GAAGC,QACHD,GAAGE,OACCF,GAAGG,UAAUC,SAAS,gBACtBN,SAAU,KAEhBhC,WACGN,SAAWsC,QACTA,SAEXjB,0BACUjC,QAAUkB,KAAKC,MAAL,aACXL,OAASd,QAAQyD,iBAAiB,sBAGvCC,WAAWxC,KAAK2B,UAAW,KAGxB3B,KAAKL,eACCA,SAAS8C,kBAGb9C,SAAW,IAAI+C,kBAAkBC,mBAC9B,MAAMC,OAAOD,aAAa,OACpBE,SAAWF,aAAaC,KACR,eAAlBC,SAASvE,MAAoD,UAA3BuE,SAASC,oBACtCnB,qBAMZ/B,OAAOqC,SAAQC,UACXvC,SAASoD,QAAQb,GAAG,CAAEc,YAAY,MACzChD,QAMViD,UACOjD,KAAKL,eACCA,SAAS8C,cAGtBS,SAAW"} \ No newline at end of file diff --git a/amd/src/modedit-modal.js b/amd/src/modedit-modal.js index eb6ddca..7fc3144 100644 --- a/amd/src/modedit-modal.js +++ b/amd/src/modedit-modal.js @@ -12,6 +12,21 @@ import {replaceNodeContents} from 'core/templates'; //import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only //import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only +/* Moodle 3.11 safe import for when needed +let markFormSubmitted = () => {}; +let notifyFormSubmittedByJavascript = () => {}; + +import('core_form/changechecker').then((ns) => { + debug.info(ns); + if(ns.markFormSubmitted) { + markFormSubmitted = ns.markFormSubmitted; + } + if(ns.notifyFormSubmittedByJavascript) { + notifyFormSubmittedByJavascript = ns.notifyFormSubmittedByJavascript; + } +}).catch(()=>{}); +*/ + export default { install(Vue/*,options*/){ diff --git a/amd/src/page-edit-plan.js b/amd/src/page-edit-plan.js index ac4f2bb..2dda426 100644 --- a/amd/src/page-edit-plan.js +++ b/amd/src/page-edit-plan.js @@ -9,7 +9,8 @@ import {get_string,get_strings} from 'core/str'; import {call} from 'core/ajax'; import notification from 'core/notification'; -import {resetAllFormDirtyStates} from 'core_form/changechecker'; + +//import {resetAllFormDirtyStates} from 'core_form/changechecker'; // Moodle 4.00+ only import Vue from './vue/vue'; @@ -36,6 +37,16 @@ Vue.use(BootstrapVue); const debug = new Debugger("treestudyplan"); +let resetAllFormDirtyStates = () => {}; +import('core_form/changechecker').then((ns) => { + debug.info(ns); + if(ns.resetAllFormDirtyStates) { + resetAllFormDirtyStates = ns.resetAllFormDirtyStates; + } +}).catch(()=>{}); + + + let strings = load_strings({ studyplan: { studyplan_select_placeholder: 'studyplan_select_placeholder', diff --git a/amd/src/util/mform-helper.js b/amd/src/util/mform-helper.js index 23e3295..189ab3e 100644 --- a/amd/src/util/mform-helper.js +++ b/amd/src/util/mform-helper.js @@ -14,6 +14,21 @@ import Debugger from './debugger'; //import {markFormSubmitted} from 'core_form/changechecker'; // Moodle 4.00+ only //import {notifyFormSubmittedByJavascript} from 'core_form/events'; // Moodle 4.00+ only +/* Moodle 3.11 safe import for when needed +let markFormSubmitted = () => {}; +let notifyFormSubmittedByJavascript = () => {}; + +import('core_form/changechecker').then((ns) => { + debug.info(ns); + if(ns.markFormSubmitted) { + markFormSubmitted = ns.markFormSubmitted; + } + if(ns.notifyFormSubmittedByJavascript) { + notifyFormSubmittedByJavascript = ns.notifyFormSubmittedByJavascript; + } +}).catch(()=>{}); +*/ + /** * Create a random UUID in both secure and insecure contexts * @returns UUID