From 299eb0e8814bb6877f0c2bc61dbcc52cdedb1b44 Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Tue, 31 Dec 2024 09:59:33 +0100 Subject: [PATCH] Reworked Vue templates in mustache for readability. --- amd/build/page-coach.min.js | 2 +- amd/build/page-coach.min.js.map | 2 +- amd/build/page-edit-plan.min.js | 2 +- amd/build/page-edit-plan.min.js.map | 2 +- amd/build/page-myreport.min.js | 2 +- amd/build/page-myreport.min.js.map | 2 +- amd/build/page-result-overview.min.js | 2 +- amd/build/page-result-overview.min.js.map | 2 +- amd/build/page-view-plan.min.js | 2 +- amd/build/page-view-plan.min.js.map | 2 +- amd/src/page-coach.js | 4 +++ amd/src/page-edit-plan.js | 10 ++++++-- amd/src/page-myreport.js | 26 ++++++++++++++------ amd/src/page-result-overview.js | 13 ++++++---- amd/src/page-view-plan.js | 10 +++++++- coach.php | 2 +- edit-plan.php | 11 ++++++--- lang/en/local_treestudyplan.php | 2 +- myreport.php | 10 +++----- result-overview.php | 9 ++++++- templates/coach.mustache | 9 +++---- templates/edit_plan.mustache | 15 ++++++------ templates/myreport.mustache | 30 +++++++++-------------- templates/result_overview.mustache | 9 ++----- templates/view_plan.mustache | 19 +++++++------- view-plan.php | 8 ++++-- 26 files changed, 118 insertions(+), 89 deletions(-) diff --git a/amd/build/page-coach.min.js b/amd/build/page-coach.min.js index 0bd4d97..27fda4f 100644 --- a/amd/build/page-coach.min.js +++ b/amd/build/page-coach.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-coach",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-processor","./util/date-helper","./util/browserbuttonevents","./studyplan-editor-components","./treestudyplan-components","./report-viewer-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_browserbuttonevents,_studyplanEditorComponents,_treestudyplanComponents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){let app=new _vue.default({el:"#root",data:{selected:{planid:0,studentid:0},displayedstudyplan:null,activestudyplan:null,associatedstudents:[],selectedstudent:null,studentstudyplan:null,loadingstudyplan:!1,studyplans:[],text:strings.coach,toolbox:{right:!0},usedcontexts:[],editmode:!1},async mounted(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_coaching_studyplans",args:{}}])[0].then((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&&""!=parts[0])for(let idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1],!1);break}})).catch(_notification.default.exception),(0,_browserbuttonevents.addBrowserButtonEvent)(this.navChanged,this.navChanged)},computed:{studentcount(){let count=0;for(const group of app.associatedstudents)count+=group.users.length;return count}},methods:{navChanged(){const hash=window.location.hash.replace("#",""),parts=hash.split("-");if(debug.log("Navigation changed",hash,parts),parts&&parts.length>0){const planid=Number(parts[0]),studentid=parts.length>1?Number(parts[1]):0;if(debug.log("Selected ids",planid,studentid,this.selected.planid,this.selected.studentid),0==planid)planid!=this.selected.planid&&this.closeStudyplan(!1);else if(this.selected.planid!=planid||0==studentid&&0!=this.selected.studentid){debug.info("Requested plan changed - loading studyplan");for(let idx in app.studyplans){const plan=this.studyplans[idx];if(Number(plan.id)==planid){this.selectStudyplan(plan,studentid,!1);break}}}else if(this.selected.studentid!=studentid)for(const group of app.associatedstudents)for(const student of group.users)if(Number(student.id)==studentid){app.showStudentView(student,!1);break}}},closeStudyplan(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];app.selected.planid=0,app.selected.studentid=0,app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,updatehash&&(window.location.hash="")},selectStudyplan(studyplan,studentid){let updatehash=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];app.selected.planid=Number(studyplan.id),app.selected.studentid=studentid?Number(studentid):0;const self=this;self.loadingstudyplan=!0,self.associatedstudents=[],self.selectedstudent=null,self.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].then((response=>{self.activestudyplan=(0,_studyplanProcessor.processStudyplan)(response,!0),(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated_grouped",args:{studyplan_id:studyplan.id}}])[0].then((function(response){self.associatedstudents=response;let foundstudent=!1;if(studentid)for(const group of self.associatedstudents)for(const student of group.users)if(student.id==studentid){foundstudent=!0,self.showStudentView(student);break}if(!foundstudent)for(const group of self.associatedstudents)for(const student of group.users){foundstudent=!0,self.showStudentView(student);break}foundstudent||(app.selected.studentid=0,updatehash&&(window.location.hash=app.activestudyplan.id),self.displayedstudyplan=self.activestudyplan,self.loadingstudyplan=!1)})).catch(_notification.default.exception)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){let updatehash=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];app.selected.studentid=student?Number(student.id):0,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].then((response=>{app.studentstudyplan=(0,_studyplanProcessor.processStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,updatehash&&(window.location.hash=app.activestudyplan.id+"-"+student.id)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))):this.showOverview(updatehash)},showOverview(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];debug.info("Switch to overview",updatehash),app.selected.studentid=0,app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,updatehash&&(window.location.hash=app.activestudyplan.id)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);let debug=new _debugger.default("treestudyplancoach"),strings=(0,_stringHelper.loadStrings)({coach:{}})})); +define("local_treestudyplan/page-coach",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-processor","./util/date-helper","./util/browserbuttonevents","./studyplan-editor-components","./treestudyplan-components","./report-viewer-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_browserbuttonevents,_studyplanEditorComponents,_treestudyplanComponents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){let app=new _vue.default({el:"#root",data:{selected:{planid:0,studentid:0},displayedstudyplan:null,activestudyplan:null,associatedstudents:[],selectedstudent:null,studentstudyplan:null,loadingstudyplan:!1,studyplans:[],text:strings.coach,toolbox:{right:!0},usedcontexts:[],editmode:!1},async mounted(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_coaching_studyplans",args:{}}])[0].then((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&&""!=parts[0])for(let idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1],!1);break}})).catch(_notification.default.exception),(0,_browserbuttonevents.addBrowserButtonEvent)(this.navChanged,this.navChanged)},computed:{studentcount(){let count=0;for(const group of app.associatedstudents)count+=group.users.length;return count}},methods:{navChanged(){const hash=window.location.hash.replace("#",""),parts=hash.split("-");if(debug.log("Navigation changed",hash,parts),parts&&parts.length>0){const planid=Number(parts[0]),studentid=parts.length>1?Number(parts[1]):0;if(debug.log("Selected ids",planid,studentid,this.selected.planid,this.selected.studentid),0==planid)planid!=this.selected.planid&&this.closeStudyplan(!1);else if(this.selected.planid!=planid||0==studentid&&0!=this.selected.studentid){debug.info("Requested plan changed - loading studyplan");for(let idx in app.studyplans){const plan=this.studyplans[idx];if(Number(plan.id)==planid){this.selectStudyplan(plan,studentid,!1);break}}}else if(this.selected.studentid!=studentid)for(const group of app.associatedstudents)for(const student of group.users)if(Number(student.id)==studentid){app.showStudentView(student,!1);break}}},closeStudyplan(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];app.selected.planid=0,app.selected.studentid=0,app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,updatehash&&(window.location.hash="")},selectStudyplan(studyplan,studentid){let updatehash=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];app.selected.planid=Number(studyplan.id),app.selected.studentid=studentid?Number(studentid):0;const self=this;self.loadingstudyplan=!0,self.associatedstudents=[],self.selectedstudent=null,self.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].then((response=>{self.activestudyplan=(0,_studyplanProcessor.processStudyplan)(response,!0),(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated_grouped",args:{studyplan_id:studyplan.id}}])[0].then((function(response){self.associatedstudents=response;let foundstudent=!1;if(studentid)for(const group of self.associatedstudents)for(const student of group.users)if(student.id==studentid){foundstudent=!0,self.showStudentView(student);break}if(!foundstudent)for(const group of self.associatedstudents)for(const student of group.users){foundstudent=!0,self.showStudentView(student);break}foundstudent||(app.selected.studentid=0,updatehash&&(window.location.hash=app.activestudyplan.id),self.displayedstudyplan=self.activestudyplan,self.loadingstudyplan=!1)})).catch(_notification.default.exception)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){let updatehash=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];app.selected.studentid=student?Number(student.id):0,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].then((response=>{app.studentstudyplan=(0,_studyplanProcessor.processStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,updatehash&&(window.location.hash=app.activestudyplan.id+"-"+student.id)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))):this.showOverview(updatehash)},showOverview(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];debug.info("Switch to overview",updatehash),app.selected.studentid=0,app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,updatehash&&(window.location.hash=app.activestudyplan.id)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);let debug=new _debugger.default("treestudyplancoach"),strings=(0,_stringHelper.loadStrings)({coach:{back:"back",selectstudentBtn:"selectstudent_btn",coacheditmode:"coacheditmode",showoverview:"showoverview"}})})); //# sourceMappingURL=page-coach.min.js.map \ No newline at end of file diff --git a/amd/build/page-coach.min.js.map b/amd/build/page-coach.min.js.map index ba8ebf3..d361eb0 100644 --- a/amd/build/page-coach.min.js.map +++ b/amd/build/page-coach.min.js.map @@ -1 +1 @@ -{"version":3,"file":"page-coach.min.js","sources":["../src/page-coach.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 promise/no-nesting: \"off\" */\n/* eslint max-depth: [\"error\", 6]*/\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 {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\n\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(\"treestudyplancoach\");\n\nlet strings = loadStrings({\n coach: {\n },\n});\n\n/**\n * Initialize the Page\n */\nexport function init() {\n let app = new Vue({\n el: '#root',\n data: {\n selected: {\n planid: 0,\n studentid: 0,\n },\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.coach,\n toolbox: {\n right: true,\n },\n usedcontexts: [],\n editmode: false,\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_coaching_studyplans',\n args: {}\n }])[0].then(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 } 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 && parts[0] != '') {\n for (let idx in app.studyplans) {\n if (app.studyplans[idx].id == parts[0]) {\n app.selectStudyplan(app.studyplans[idx], parts[1], false);\n break;\n }\n }\n }\n return;\n }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\n studentcount() {\n let count = 0;\n for (const group of app.associatedstudents) {\n count += group.users.length;\n }\n return count;\n }\n },\n methods: {\n navChanged() {\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n debug.log(\"Navigation changed\", hash, parts);\n\n if (!!parts && parts.length > 0) {\n const planid = Number(parts[0]);\n const studentid = (parts.length > 1) ? Number(parts[1]) : 0;\n\n debug.log(\"Selected ids\", planid, studentid, this.selected.planid, this.selected.studentid);\n if (planid == 0) {\n if (planid != this.selected.planid) {\n this.closeStudyplan(false);\n }\n } else if (this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0)) {\n debug.info(\"Requested plan changed - loading studyplan\");\n for (let idx in app.studyplans) {\n const plan = this.studyplans[idx];\n if (Number(plan.id) == planid) {\n this.selectStudyplan(plan, studentid, false);\n break;\n }\n }\n } else if (this.selected.studentid != studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (Number(student.id) == studentid) {\n app.showStudentView(student, false);\n break;\n }\n }\n }\n }\n }\n },\n closeStudyplan(updatehash = true) {\n app.selected.planid = 0;\n app.selected.studentid = 0;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n if (updatehash) {\n window.location.hash = '';\n }\n },\n\n selectStudyplan(studyplan, studentid, updatehash = true) {\n app.selected.planid = Number(studyplan.id);\n app.selected.studentid = studentid ? Number(studentid) : 0;\n // Fetch studyplan\n const self = this;\n self.loadingstudyplan = true;\n self.associatedstudents = [];\n self.selectedstudent = null;\n self.studentstudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: {id: studyplan.id}\n }])[0].then((response) => {\n self.activestudyplan = processStudyplan(response, true);\n\n call([{\n methodname: 'local_treestudyplan_all_associated_grouped',\n args: {'studyplan_id': studyplan.id}\n }])[0].then(function(response) {\n self.associatedstudents = response;\n let foundstudent = false;\n if (studentid) {\n for (const group of self.associatedstudents) {\n for (const student of group.users) {\n if (student.id == studentid) {\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n }\n if (!foundstudent) {\n // Select first student available.\n for (const group of self.associatedstudents) {\n for (const student of group.users) {\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n if (!foundstudent) {\n // Update hash with just the studyplan if no student was available for display\n app.selected.studentid = 0;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n self.displayedstudyplan = self.activestudyplan;\n self.loadingstudyplan = false;\n }\n return;\n }).catch(notification.exception);\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student, updatehash = true) {\n app.selected.studentid = student ? Number(student.id) : 0;\n if (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].then((response) => {\n app.studentstudyplan = processStudyplan(response, false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n } else {\n this.showOverview(updatehash);\n }\n },\n showOverview(updatehash = true) {\n debug.info(\"Switch to overview\", updatehash);\n app.selected.studentid = 0;\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n }\n\n },\n });\n}\n"],"names":["app","Vue","el","data","selected","planid","studentid","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","coach","toolbox","right","usedcontexts","editmode","methodname","args","then","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","catch","notification","exception","this","navChanged","computed","studentcount","count","group","users","methods","debug","log","Number","closeStudyplan","info","plan","student","showStudentView","updatehash","studyplan","self","foundstudent","error","userid","studyplanid","showOverview","use","EditorComponents","TSComponents","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"ixBAkDQA,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,SAAU,CACNC,OAAQ,EACRC,UAAW,GAEfC,mBAAoB,KACpBC,gBAAiB,KACjBC,mBAAoB,GACpBC,gBAAiB,KACjBC,iBAAkB,KAClBC,kBAAkB,EAClBC,WAAY,GACZC,KAAMC,QAAQC,MACdC,QAAS,CACLC,OAAO,GAEXC,aAAc,GACdC,UAAU,kCAGL,CAAC,CACFC,WAAY,+CACZC,KAAM,MACN,GAAGC,M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B4D,aACA5B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,IAE/CuB,KAAK7D,mBAAqB6D,KAAK5D,gBAC/B4D,KAAKxD,kBAAmB,MAG7BmC,MAAMC,sBAAaC,cAEvBF,OAAM,SAASuB,6BACDrB,UAAUqB,OACvBtE,IAAIY,kBAAmB,MAG/BqD,gBAAgBD,aAASE,sEACrBlE,IAAII,SAASE,UAAY0D,QAAUJ,OAAOI,QAAQnB,IAAM,EACpDmB,SACAhE,IAAIU,gBAAkBsD,QACtBhE,IAAIW,iBAAmB,KACvBX,IAAIY,kBAAmB,iBAClB,CAAC,CACFS,WAAY,yCACZC,KAAM,CAACiD,OAAQP,QAAQnB,GAAI2B,YAAaxE,IAAIQ,gBAAgBqC,OAC5D,GAAGtB,MAAMC,WACTxB,IAAIW,kBAAmB,wCAAiBa,UAAU,GAClDxB,IAAIO,mBAAqBP,IAAIW,iBAC7BX,IAAIY,kBAAmB,EACnBsD,aACA5B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,GAAK,IAAMmB,QAAQnB,OAGnEE,OAAM,SAASuB,6BACDrB,UAAUqB,OACvBtE,IAAIY,kBAAmB,WAGtB6D,aAAaP,aAG1BO,mBAAaP,sEACTR,MAAMI,KAAK,qBAAsBI,YACjClE,IAAII,SAASE,UAAY,EACzBN,IAAIU,gBAAkB,KACtBV,IAAIW,iBAAmB,KACvBX,IAAIO,mBAAqBP,IAAIQ,gBACzB0D,aACA5B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,8gBAxO3D6B,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,8CAGJH,IAAII,oCAGJJ,IAAIK,iCAEJL,IAAIM,2BAGJtB,MAAQ,IAAIuB,kBAAS,sBAErBlE,SAAU,6BAAY,CACtBC,MAAO"} \ No newline at end of file +{"version":3,"file":"page-coach.min.js","sources":["../src/page-coach.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 promise/no-nesting: \"off\" */\n/* eslint max-depth: [\"error\", 6]*/\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 {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\n\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(\"treestudyplancoach\");\n\nlet strings = loadStrings({\n coach: {\n back: \"back\",\n selectstudentBtn: \"selectstudent_btn\",\n coacheditmode: \"coacheditmode\",\n showoverview: \"showoverview\",\n },\n});\n\n/**\n * Initialize the Page\n */\nexport function init() {\n let app = new Vue({\n el: '#root',\n data: {\n selected: {\n planid: 0,\n studentid: 0,\n },\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.coach,\n toolbox: {\n right: true,\n },\n usedcontexts: [],\n editmode: false,\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_coaching_studyplans',\n args: {}\n }])[0].then(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 } 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 && parts[0] != '') {\n for (let idx in app.studyplans) {\n if (app.studyplans[idx].id == parts[0]) {\n app.selectStudyplan(app.studyplans[idx], parts[1], false);\n break;\n }\n }\n }\n return;\n }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\n studentcount() {\n let count = 0;\n for (const group of app.associatedstudents) {\n count += group.users.length;\n }\n return count;\n }\n },\n methods: {\n navChanged() {\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n debug.log(\"Navigation changed\", hash, parts);\n\n if (!!parts && parts.length > 0) {\n const planid = Number(parts[0]);\n const studentid = (parts.length > 1) ? Number(parts[1]) : 0;\n\n debug.log(\"Selected ids\", planid, studentid, this.selected.planid, this.selected.studentid);\n if (planid == 0) {\n if (planid != this.selected.planid) {\n this.closeStudyplan(false);\n }\n } else if (this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0)) {\n debug.info(\"Requested plan changed - loading studyplan\");\n for (let idx in app.studyplans) {\n const plan = this.studyplans[idx];\n if (Number(plan.id) == planid) {\n this.selectStudyplan(plan, studentid, false);\n break;\n }\n }\n } else if (this.selected.studentid != studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (Number(student.id) == studentid) {\n app.showStudentView(student, false);\n break;\n }\n }\n }\n }\n }\n },\n closeStudyplan(updatehash = true) {\n app.selected.planid = 0;\n app.selected.studentid = 0;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n if (updatehash) {\n window.location.hash = '';\n }\n },\n\n selectStudyplan(studyplan, studentid, updatehash = true) {\n app.selected.planid = Number(studyplan.id);\n app.selected.studentid = studentid ? Number(studentid) : 0;\n // Fetch studyplan\n const self = this;\n self.loadingstudyplan = true;\n self.associatedstudents = [];\n self.selectedstudent = null;\n self.studentstudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: {id: studyplan.id}\n }])[0].then((response) => {\n self.activestudyplan = processStudyplan(response, true);\n\n call([{\n methodname: 'local_treestudyplan_all_associated_grouped',\n args: {'studyplan_id': studyplan.id}\n }])[0].then(function(response) {\n self.associatedstudents = response;\n let foundstudent = false;\n if (studentid) {\n for (const group of self.associatedstudents) {\n for (const student of group.users) {\n if (student.id == studentid) {\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n }\n if (!foundstudent) {\n // Select first student available.\n for (const group of self.associatedstudents) {\n for (const student of group.users) {\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n if (!foundstudent) {\n // Update hash with just the studyplan if no student was available for display\n app.selected.studentid = 0;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n self.displayedstudyplan = self.activestudyplan;\n self.loadingstudyplan = false;\n }\n return;\n }).catch(notification.exception);\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student, updatehash = true) {\n app.selected.studentid = student ? Number(student.id) : 0;\n if (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].then((response) => {\n app.studentstudyplan = processStudyplan(response, false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n } else {\n this.showOverview(updatehash);\n }\n },\n showOverview(updatehash = true) {\n debug.info(\"Switch to overview\", updatehash);\n app.selected.studentid = 0;\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n }\n\n },\n });\n}\n"],"names":["app","Vue","el","data","selected","planid","studentid","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","coach","toolbox","right","usedcontexts","editmode","methodname","args","then","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","catch","notification","exception","this","navChanged","computed","studentcount","count","group","users","methods","debug","log","Number","closeStudyplan","info","plan","student","showStudentView","updatehash","studyplan","self","foundstudent","error","userid","studyplanid","showOverview","use","EditorComponents","TSComponents","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","back","selectstudentBtn","coacheditmode","showoverview"],"mappings":"ixBAsDQA,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,SAAU,CACNC,OAAQ,EACRC,UAAW,GAEfC,mBAAoB,KACpBC,gBAAiB,KACjBC,mBAAoB,GACpBC,gBAAiB,KACjBC,iBAAkB,KAClBC,kBAAkB,EAClBC,WAAY,GACZC,KAAMC,QAAQC,MACdC,QAAS,CACLC,OAAO,GAEXC,aAAc,GACdC,UAAU,kCAGL,CAAC,CACFC,WAAY,+CACZC,KAAM,MACN,GAAGC,MAAK,SAASC,gBACXC,UAAY,CAACC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GAChDJ,SAASK,MAAK,CAACC,EAAGC,WACRC,SAAU,+BAAgBF,GAC1BG,SAAU,+BAAgBF,GAE1BG,EAAIT,UAAUO,SAAWP,UAAUQ,gBAChC,GAALC,EAEOJ,EAAEK,KAAKC,cAAcL,EAAEI,MAEvBD,KAGflC,IAAIa,WAAaW,eAGXa,MADOC,OAAOC,SAASC,KAAKC,QAAQ,IAAK,IAC5BC,MAAM,QAEnBL,OAASA,MAAMM,OAAS,GAAiB,IAAZN,MAAM,OAChC,IAAIO,OAAO5C,IAAIa,cACZb,IAAIa,WAAW+B,KAAKC,IAAMR,MAAM,GA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axE,IAAIQ,gBAAgBqC,OAC5D,GAAGtB,MAAMC,WACTxB,IAAIW,kBAAmB,wCAAiBa,UAAU,GAClDxB,IAAIO,mBAAqBP,IAAIW,iBAC7BX,IAAIY,kBAAmB,EACnBsD,aACA5B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,GAAK,IAAMmB,QAAQnB,OAGnEE,OAAM,SAASuB,6BACDrB,UAAUqB,OACvBtE,IAAIY,kBAAmB,WAGtB6D,aAAaP,aAG1BO,mBAAaP,sEACTR,MAAMI,KAAK,qBAAsBI,YACjClE,IAAII,SAASE,UAAY,EACzBN,IAAIU,gBAAkB,KACtBV,IAAIW,iBAAmB,KACvBX,IAAIO,mBAAqBP,IAAIQ,gBACzB0D,aACA5B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,8gBA5O3D6B,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,8CAGJH,IAAII,oCAGJJ,IAAIK,iCAEJL,IAAIM,2BAGJtB,MAAQ,IAAIuB,kBAAS,sBAErBlE,SAAU,6BAAY,CACtBC,MAAO,CACHkE,KAAM,OACNC,iBAAkB,oBAClBC,cAAe,gBACfC,aAAc"} \ 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 405ce8c..65916e0 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/ajax","core/notification","./vue/vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./util/debugger","./util/browserbuttonevents","./util/string-helper","./studyplan-processor","./downloader","./util/date-helper","./util/mform-helper","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_browserbuttonevents,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_mformHelper,_portalVue,_bootstrapVue){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid,options){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;debug.info("options",options),null===options||"object"!=typeof options||Array.isArray(options)?options={defaultAggregation:"core"}:options.defaultAggregation||(options.defaultAggregation="core");let app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",idnumber:"",slots:4,startdate:"2020-08-01",enddate:"",context:contextid,aggregation:options.defaultAggregation,aggregation_config:""}},activestudyplan:null,activepage:null,loadingstudyplan:!1,studyplans:[],templatecount:0,text:strings.studyplan,usedcontexts:[]},created(){this.$root.$on("studyplanRemoved",(studyplan=>{app.activestudyplan==studyplan&&(app.activestudyplan=null);let index=null;for(let idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted(){this.initialize(),(0,_browserbuttonevents.addBrowserButtonEvent)(this.backPressed)},beforeunmount(){},computed:{dropdownTitle(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},methods:{backPressed(){debug.log("Back button pressed"),app.activestudyplan&&(debug.log("Closing studyplan"),this.closeStudyplan())},initialize(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].then((function(response){const timingval={future:0,present:1,past:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b);let t=timingval[timinga]-timingval[timingb];return 0==t&&(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime(),0==t&&(t=a.name.localeCompare(b.name))),t})),app.studyplans=response;const hash=location.hash.replace("#","");if(hash){const id=hash;for(const p of app.studyplans)if(p.id==id){app.selectStudyplan(id);break}}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_available_categories",args:{operation:"edit",refcontext_id:contextid}}])[0].then((function(response){app.usedcontexts=response})).catch(_notification.default.exception),this.refreshTemplateCount()},refreshTemplateCount(){(0,_ajax.call)([{methodname:"local_treestudyplan_count_templates",args:{}}])[0].then((function(response){app.templatecount=response})).catch(_notification.default.exception)},closeStudyplan(){app.activestudyplan=null,window.location.hash=""},movedStudyplan(plan,from,to){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),setTimeout((()=>{window.location.search=params.toString()}),50)},onStudyPlanCreated(newstudyplan){if(newstudyplan.context_id!=contextid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",newstudyplan.context_id),resetAllFormDirtyStates(),window.location=window.location.pathname+"?"+params.toString()+"#"+newstudyplan.id}else app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan.id)},switchContext(ctxid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",ctxid),setTimeout((()=>{window.location.href=window.location.pathname+"?"+params.toString()}),50)},selectStudyplan(studyplanid){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplanid}}])[0].then((function(response){app.activestudyplan=(0,_studyplanProcessor.processStudyplan)(response),debug.info("studyplan processed"),app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},importStudyplan(){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")}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_mformHelper=_interopRequireDefault(_mformHelper),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue);var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_mformHelper.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);const debug=new _debugger.default("treestudyplan");let resetAllFormDirtyStates=()=>{};("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require(["core_form/changechecker"],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require("core_form/changechecker")):Promise.resolve(_systemImportTransformerGlobalIdentifier["core_form/changechecker"])).then((ns=>{debug.info(ns),ns.resetAllFormDirtyStates&&(resetAllFormDirtyStates=ns.resetAllFormDirtyStates)})).catch((()=>{}));let strings=(0,_stringHelper.loadStrings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder",advanced_import_from_file:"advanced_import_from_file",advanced_create_from_template:"advanced_create_from_template",studyplan_add:"studyplan_add"}})})); +define("local_treestudyplan/page-edit-plan",["exports","core/ajax","core/notification","./vue/vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./util/debugger","./util/browserbuttonevents","./util/string-helper","./studyplan-processor","./downloader","./util/date-helper","./util/mform-helper","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_browserbuttonevents,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_mformHelper,_portalVue,_bootstrapVue){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid,contextname,options){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;debug.info("options",options),null===options||"object"!=typeof options||Array.isArray(options)?options={defaultAggregation:"core"}:options.defaultAggregation||(options.defaultAggregation="core");let app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",idnumber:"",slots:4,startdate:"2020-08-01",enddate:"",context:contextid,aggregation:options.defaultAggregation,aggregation_config:""}},activestudyplan:null,activepage:null,loadingstudyplan:!1,studyplans:[],templatecount:0,contextname:contextname,text:strings.studyplan,usedcontexts:[]},created(){this.$root.$on("studyplanRemoved",(studyplan=>{app.activestudyplan==studyplan&&(app.activestudyplan=null);let index=null;for(let idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted(){this.initialize(),(0,_browserbuttonevents.addBrowserButtonEvent)(this.backPressed)},beforeunmount(){},computed:{dropdownTitle(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},methods:{backPressed(){debug.log("Back button pressed"),app.activestudyplan&&(debug.log("Closing studyplan"),this.closeStudyplan())},initialize(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].then((function(response){const timingval={future:0,present:1,past:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b);let t=timingval[timinga]-timingval[timingb];return 0==t&&(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime(),0==t&&(t=a.name.localeCompare(b.name))),t})),app.studyplans=response;const hash=location.hash.replace("#","");if(hash){const id=hash;for(const p of app.studyplans)if(p.id==id){app.selectStudyplan(id);break}}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_available_categories",args:{operation:"edit",refcontext_id:contextid}}])[0].then((function(response){app.usedcontexts=response})).catch(_notification.default.exception),this.refreshTemplateCount()},refreshTemplateCount(){(0,_ajax.call)([{methodname:"local_treestudyplan_count_templates",args:{}}])[0].then((function(response){app.templatecount=response})).catch(_notification.default.exception)},closeStudyplan(){app.activestudyplan=null,window.location.hash=""},movedStudyplan(plan,from,to){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),setTimeout((()=>{window.location.search=params.toString()}),50)},onStudyPlanCreated(newstudyplan){if(newstudyplan.context_id!=contextid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",newstudyplan.context_id),resetAllFormDirtyStates(),window.location=window.location.pathname+"?"+params.toString()+"#"+newstudyplan.id}else app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan.id)},switchContext(ctxid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",ctxid),setTimeout((()=>{window.location.href=window.location.pathname+"?"+params.toString()}),50)},selectStudyplan(studyplanid){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplanid}}])[0].then((function(response){app.activestudyplan=(0,_studyplanProcessor.processStudyplan)(response),debug.info("studyplan processed"),app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},importStudyplan(){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")}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_mformHelper=_interopRequireDefault(_mformHelper),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue);var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_mformHelper.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);const debug=new _debugger.default("treestudyplan");let resetAllFormDirtyStates=()=>{};("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require(["core_form/changechecker"],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require("core_form/changechecker")):Promise.resolve(_systemImportTransformerGlobalIdentifier["core_form/changechecker"])).then((ns=>{debug.info(ns),ns.resetAllFormDirtyStates&&(resetAllFormDirtyStates=ns.resetAllFormDirtyStates)})).catch((()=>{}));let strings=(0,_stringHelper.loadStrings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder",advanced_import_from_file:"advanced_import_from_file",advanced_create_from_template:"advanced_create_from_template",studyplan_add:"studyplan_add",loading:"loading@core",back:"back",studyplanSelect:"studyplan_select",defaultaggregation:"defaultaggregation",studyplanNoneselected:"studyplan_noneselected"}})})); //# 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 3636df5..fe657bc 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 no-empty-function: \"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\n// Commented out: import {resetAllFormDirtyStates} from 'core_form/changechecker'; // Moodle 4.00+ only\n\nimport Vue from './vue/vue';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\nimport Debugger from './util/debugger';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {download, upload} from './downloader';\nimport {studyplanTiming} from './util/date-helper';\nimport mFormComponents from \"./util/mform-helper\";\nVue.use(mFormComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nconst debug = new Debugger(\"treestudyplan\");\n\nlet resetAllFormDirtyStates = () => { };\nimport('core_form/changechecker').then((ns) => {\n debug.info(ns);\n if (ns.resetAllFormDirtyStates) {\n resetAllFormDirtyStates = ns.resetAllFormDirtyStates;\n }\n return;\n}).catch(()=>{});\n\nlet strings = loadStrings({\n studyplan: {\n 'studyplan_select_placeholder': 'studyplan_select_placeholder',\n 'advanced_import_from_file': 'advanced_import_from_file',\n 'advanced_create_from_template': 'advanced_create_from_template',\n 'studyplan_add': \"studyplan_add\",\n },\n});\n\n/**\n * Initialize the Page\n * @param {int} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)\n * @param {object} options Options to be passed to this script\n */\nexport function init(contextid, categoryid, options) {\n // Make sure the id's are numeric and integer\n if (undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1) {\n contextid = 1;\n } else {\n contextid = Number(contextid); // Ensure a numeric value instead of string\n }\n if (undefined === categoryid || !Number.isInteger(Number(categoryid))) {\n categoryid = 0;\n } else {\n categoryid = Number(categoryid); // Ensure a numeric value instead of string\n }\n\n debug.info(\"options\", options);\n if (options !== null && typeof options === 'object' && !Array.isArray(options)) {\n if (!options.defaultAggregation) {\n options.defaultAggregation = \"core\";\n }\n \n } else {\n options = {defaultAggregation: \"core\"};\n }\n\n // Setup the initial Vue app for this page\n let app = new Vue({\n el: '#root',\n data: {\n create: {\n studyplan: {\n name: '',\n shortname: '',\n description: '',\n idnumber: '',\n slots: 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: options.defaultAggregation,\n 'aggregation_config': '',\n }\n },\n\n activestudyplan: null,\n activepage: null,\n loadingstudyplan: false,\n studyplans: [],\n templatecount: 0,\n\n text: strings.studyplan,\n usedcontexts: [],\n },\n created() {\n this.$root.$on('studyplanRemoved', (studyplan)=>{\n\n if (app.activestudyplan == studyplan) {\n app.activestudyplan = null;\n }\n\n // Remove studyplan from index list\n let index = null;\n for (let idx in app.studyplans) {\n if (app.studyplans[idx].id == studyplan.id) {\n index = idx;\n break;\n }\n }\n if (index) {\n app.studyplans.splice(index, 1);\n }\n\n });\n },\n mounted() {\n this.initialize();\n addBrowserButtonEvent(this.backPressed);\n },\n beforeunmount() {\n\n },\n computed: {\n dropdownTitle() {\n if (this.activestudyplan && this.activestudyplan.name) {\n return this.activestudyplan.name;\n } else {\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid() {\n return contextid;\n },\n\n },\n methods: {\n backPressed() {\n debug.log(\"Back button pressed\");\n if (app.activestudyplan) {\n debug.log(\"Closing studyplan\");\n this.closeStudyplan();\n }\n },\n initialize() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: {'context_id': contextid}\n }])[0].then(function(response) {\n const timingval = {future: 0, present: 1, past: 2};\n response.sort((a, b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n \n let t = timingval[timinga] - timingval[timingb];\n if (t == 0) {\n // Sort by start date if timing is equal\n t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();\n \n if (t == 0) {\n // Sort by name if timing is equal\n t = a.name.localeCompare(b.name);\n }\n }\n return t;\n });\n app.studyplans = response;\n \n // Load studyplan from hash if applicable\n const hash = location.hash.replace('#', '');\n if (hash) {\n const id = hash;\n for (const p of app.studyplans) {\n if (p.id == id) {\n app.selectStudyplan(id);\n break;\n }\n }\n }\n return;\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 return;\n }).catch(notification.exception);\n\n this.refreshTemplateCount();\n },\n refreshTemplateCount() {\n call([{\n methodname: 'local_treestudyplan_count_templates',\n args: { }\n }])[0].then(function(response) {\n app.templatecount = response;\n return;\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 return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n importStudyplan() {\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 return;\n }).catch(notification.exception);\n }, \"application/json\");\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","activestudyplan","activepage","loadingstudyplan","studyplans","templatecount","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","initialize","this","backPressed","beforeunmount","computed","dropdownTitle","studyplan_select_placeholder","methods","log","closeStudyplan","methodname","args","then","response","timingval","future","present","past","sort","a","b","timinga","timingb","t","Date","getTime","localeCompare","hash","location","replace","p","selectStudyplan","catch","notification","exception","operation","refreshTemplateCount","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","setTimeout","toString","onStudyPlanCreated","newstudyplan","context_id","resetAllFormDirtyStates","pathname","push","switchContext","ctxid","href","studyplanid","error","importStudyplan","self","filename","content","format","success","msg","use","EditorComponents","TSComponents","ModalComponents","mFormComponents","P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,0DACI,8CAChB"} \ 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 no-empty-function: \"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\n// Commented out: import {resetAllFormDirtyStates} from 'core_form/changechecker'; // Moodle 4.00+ only\n\nimport Vue from './vue/vue';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\nimport Debugger from './util/debugger';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {download, upload} from './downloader';\nimport {studyplanTiming} from './util/date-helper';\nimport mFormComponents from \"./util/mform-helper\";\nVue.use(mFormComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nconst debug = new Debugger(\"treestudyplan\");\n\nlet resetAllFormDirtyStates = () => { };\nimport('core_form/changechecker').then((ns) => {\n debug.info(ns);\n if (ns.resetAllFormDirtyStates) {\n resetAllFormDirtyStates = ns.resetAllFormDirtyStates;\n }\n return;\n}).catch(()=>{});\n\nlet strings = loadStrings({\n studyplan: {\n 'studyplan_select_placeholder': 'studyplan_select_placeholder',\n 'advanced_import_from_file': 'advanced_import_from_file',\n 'advanced_create_from_template': 'advanced_create_from_template',\n 'studyplan_add': \"studyplan_add\",\n 'loading': \"loading@core\",\n 'back': \"back\",\n 'studyplanSelect': \"studyplan_select\",\n 'defaultaggregation': \"defaultaggregation\",\n 'studyplanNoneselected': \"studyplan_noneselected\",\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 {string} contextname Name of the current context\n * @param {object} options Options to be passed to this script\n */\nexport function init(contextid, categoryid, contextname, options) {\n // Make sure the id's are numeric and integer\n if (undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1) {\n contextid = 1;\n } else {\n contextid = Number(contextid); // Ensure a numeric value instead of string\n }\n if (undefined === categoryid || !Number.isInteger(Number(categoryid))) {\n categoryid = 0;\n } else {\n categoryid = Number(categoryid); // Ensure a numeric value instead of string\n }\n\n debug.info(\"options\", options);\n if (options !== null && typeof options === 'object' && !Array.isArray(options)) {\n if (!options.defaultAggregation) {\n options.defaultAggregation = \"core\";\n }\n \n } else {\n options = {defaultAggregation: \"core\"};\n }\n\n // Setup the initial Vue app for this page\n let app = new Vue({\n el: '#root',\n data: {\n create: {\n studyplan: {\n name: '',\n shortname: '',\n description: '',\n idnumber: '',\n slots: 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: options.defaultAggregation,\n 'aggregation_config': '',\n }\n },\n\n activestudyplan: null,\n activepage: null,\n loadingstudyplan: false,\n studyplans: [],\n templatecount: 0,\n contextname: contextname,\n text: strings.studyplan,\n usedcontexts: [],\n },\n created() {\n this.$root.$on('studyplanRemoved', (studyplan)=>{\n\n if (app.activestudyplan == studyplan) {\n app.activestudyplan = null;\n }\n\n // Remove studyplan from index list\n let index = null;\n for (let idx in app.studyplans) {\n if (app.studyplans[idx].id == studyplan.id) {\n index = idx;\n break;\n }\n }\n if (index) {\n app.studyplans.splice(index, 1);\n }\n\n });\n },\n mounted() {\n this.initialize();\n addBrowserButtonEvent(this.backPressed);\n },\n beforeunmount() {\n\n },\n computed: {\n dropdownTitle() {\n if (this.activestudyplan && this.activestudyplan.name) {\n return this.activestudyplan.name;\n } else {\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid() {\n return contextid;\n },\n\n },\n methods: {\n backPressed() {\n debug.log(\"Back button pressed\");\n if (app.activestudyplan) {\n debug.log(\"Closing studyplan\");\n this.closeStudyplan();\n }\n },\n initialize() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: {'context_id': contextid}\n }])[0].then(function(response) {\n const timingval = {future: 0, present: 1, past: 2};\n response.sort((a, b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n \n let t = timingval[timinga] - timingval[timingb];\n if (t == 0) {\n // Sort by start date if timing is equal\n t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();\n \n if (t == 0) {\n // Sort by name if timing is equal\n t = a.name.localeCompare(b.name);\n }\n }\n return t;\n });\n app.studyplans = response;\n \n // Load studyplan from hash if applicable\n const hash = location.hash.replace('#', '');\n if (hash) {\n const id = hash;\n for (const p of app.studyplans) {\n if (p.id == id) {\n app.selectStudyplan(id);\n break;\n }\n }\n }\n return;\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 return;\n }).catch(notification.exception);\n\n this.refreshTemplateCount();\n },\n refreshTemplateCount() {\n call([{\n methodname: 'local_treestudyplan_count_templates',\n args: { }\n }])[0].then(function(response) {\n app.templatecount = response;\n return;\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 return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n importStudyplan() {\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 return;\n }).catch(notification.exception);\n }, \"application/json\");\n },\n },\n });\n}\n\n"],"names":["contextid","categoryid","contextname","options","undefined","Number","isInteger","debug","info","Array","isArray","defaultAggregation","app","Vue","el","data","create","studyplan","name","shortname","description","idnumber","slots","startdate","enddate","context","aggregation","activestudyplan","activepage","loadingstudyplan","studyplans","templatecount","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","initialize","this","backPressed","beforeunmount","computed","dropdownTitle","studyplan_select_placeholder","methods","log","closeStudyplan","methodname","args","then","response","timingval","future","present","past","sort","a","b","timinga","timingb","t","Date","getTime","localeCompare","hash","location","replace","p","selectStudyplan","catch","notification","exception","operation","refreshTemplateCount","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","setTimeout","toString","onStudyPlanCreated","newstudyplan","context_id","resetAllFormDirtyStates","pathname","push","switchContext","ctxid","href","studyplanid","error","importStudyplan","self","filename","content","format","success","msg","use","EditorComponents","TSComponents","ModalComponents","mFormComponents","PortalVue","BootstrapVue","Debugger","ns"],"mappings":"ssBAwEqBA,UAAWC,WAAYC,YAAaC,SAGjDH,eADAI,IAAcJ,YAAcK,OAAOC,UAAUD,OAAOL,aAAeA,UAAY,EACnE,EAEAK,OAAOL,WAKnBC,gBAHAG,IAAcH,YAAeI,OAAOC,UAAUD,OAAOJ,aAGxCI,OAAOJ,YAFP,EAKjBM,MAAMC,KAAK,UAAWL,SACN,OAAZA,SAAuC,iBAAZA,SAAyBM,MAAMC,QAAQP,SAMlEA,QAAU,CAACQ,mBAAoB,QAL1BR,QAAQQ,qBACTR,QAAQQ,mBAAqB,YAQjCC,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,OAAQ,CACJC,UAAW,CACPC,KAAM,GACNC,UAAW,GACXC,YAAa,GACbC,SAAU,GACVC,MAAO,EACPC,UAAW,aACXC,QAAS,GACTC,QAASzB,UACT0B,YAAavB,QAAQQ,sCACC,KAI9BgB,gBAAiB,KACjBC,WAAY,KACZC,kBAAkB,EAClBC,WAAY,GACZC,cAAe,EACf7B,YAAaA,YACb8B,KAAMC,QAAQhB,UACdiB,aAAc,IAElBC,eACSC,MAAMC,IAAI,oBAAqBpB,YAE5BL,IAAIe,iBAAmBV,YACvBL,IAAIe,gBAAkB,UAItBW,MAAQ,SACP,IAAIC,OAAO3B,IAAIkB,cACZlB,IAAIkB,WAAWS,KAAKC,IAAMvB,UAAUuB,GAAI,CACxCF,MAAQC,UAIZD,OACA1B,IAAIkB,WAAWW,OAAOH,MAAO,OAKzCI,eACSC,4DACiBC,KAAKC,cAE/BC,kBAGAC,SAAU,CACNC,uBACQJ,KAAKjB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AII,mCAGJJ,IAAIK,iCAEJL,IAAIM,6BAGF7G,MAAQ,IAAI8G,kBAAS,qBAEvBtB,wBAA0B,+nBACIxC,MAAM+D,KACpC/G,MAAMC,KAAK8G,IACPA,GAAGvB,0BACHA,wBAA0BuB,GAAGvB,4BAGlCpB,OAAM,aAEL1C,SAAU,6BAAY,CACtBhB,UAAW,8BACyB,yDACH,0DACI,8CAChB,wBACN,oBACH,uBACW,sCACG,2CACG"} \ No newline at end of file diff --git a/amd/build/page-myreport.min.js b/amd/build/page-myreport.min.js index 233471a..3b04efa 100644 --- a/amd/build/page-myreport.min.js +++ b/amd/build/page-myreport.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-myreport",["exports","./vue/vue","./report-viewer-components","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_vue,_reportViewerComponents,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){let type=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"own",arg1=arguments.length>1?arguments[1]:void 0;new _vue.default({el:"#root",data:{studyplans:[],type:type,invitekey:"invited"==type?arg1:null,userid:"other"==type?arg1:null},methods:{}})},_vue=_interopRequireDefault(_vue),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default)})); +define("local_treestudyplan/page-myreport",["exports","./vue/vue","./util/string-helper","./report-viewer-components","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue","./util/settings"],(function(_exports,_vue,_stringHelper,_reportViewerComponents,_portalVue,_bootstrapVue,_settings){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){let type=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"own",key=arguments.length>1?arguments[1]:void 0,enableplansharing=arguments.length>2?arguments[2]:void 0;new _vue.default({el:"#root",data:{studyplans:[],type:type,invitekey:"invited"==type?key:null,userid:"other"==type?key:null,text:strings.myreport,enableplansharing:enableplansharing},methods:{}})},_vue=_interopRequireDefault(_vue),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);let strings=(0,_stringHelper.loadStrings)({myreport:{manageInvites:"manage_invites"}})})); //# sourceMappingURL=page-myreport.min.js.map \ No newline at end of file diff --git a/amd/build/page-myreport.min.js.map b/amd/build/page-myreport.min.js.map index f80385e..011633e 100644 --- a/amd/build/page-myreport.min.js.map +++ b/amd/build/page-myreport.min.js.map @@ -1 +1 @@ -{"version":3,"file":"page-myreport.min.js","sources":["../src/page-myreport.js"],"sourcesContent":["/* eslint no-unused-vars: \"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 Vue from './vue/vue';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n/**\n * Initialize the Page\n * @param {string} type Type of page to show\n * @param {Object} arg1 Argument1 as passed\n */\n export function init(type = \"own\", arg1) {\n let app = new Vue({\n el: '#root',\n data: {\n \"studyplans\": [],\n \"type\": type,\n \"invitekey\": (type == \"invited\") ? arg1 : null,\n \"userid\": (type == \"other\") ? arg1 : null,\n },\n methods: {\n\n },\n });\n\n}\n\n"],"names":["type","arg1","Vue","el","data","methods","use","RVComponents","PortalVue","BootstrapVue"],"mappings":"+YAoBsBA,4DAAO,MAAOC,4CACtB,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,YACY,QACNJ,eACc,WAARA,KAAqBC,KAAO,YACvB,SAARD,KAAmBC,KAAO,MAEzCI,QAAS,+NArBbC,IAAIC,8CAGJD,IAAIE,iCAEJF,IAAIG"} \ No newline at end of file +{"version":3,"file":"page-myreport.min.js","sources":["../src/page-myreport.js"],"sourcesContent":["/* eslint no-unused-vars: \"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 Vue from './vue/vue';\n\nimport {loadStrings} from './util/string-helper';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nimport { settings } from './util/settings';\nVue.use(BootstrapVue);\n\nlet strings = loadStrings({\n myreport: {\n manageInvites: \"manage_invites\",\n },\n});\n\n/**\n * Initialize the Page\n * @param {string} type Type of page to show\n * @param {Object} key Invitekey or userid of another user\n * @param {boolean} enableplansharing True if studyplan sharing is enabled\n */\n export function init(type = \"own\", key, enableplansharing) {\n let app = new Vue({\n el: '#root',\n data: {\n studyplans: [],\n type: type,\n invitekey: (type == \"invited\") ? key : null,\n userid: (type == \"other\") ? key : null,\n text: strings.myreport,\n enableplansharing: enableplansharing,\n },\n methods: {\n },\n });\n\n}\n\n"],"names":["type","key","enableplansharing","Vue","el","data","studyplans","invitekey","userid","text","strings","myreport","methods","use","RVComponents","PortalVue","BootstrapVue","manageInvites"],"mappings":"gdA6BsBA,4DAAO,MAAOC,2CAAKC,yDAC3B,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,WAAY,GACZN,KAAMA,KACNO,UAAoB,WAARP,KAAqBC,IAAM,KACvCO,OAAiB,SAARR,KAAmBC,IAAM,KAClCQ,KAAMC,QAAQC,SACdT,kBAAmBA,mBAEvBU,QAAS,+NA9BbC,IAAIC,8CAEJD,IAAIE,iCAGJF,IAAIG,2BAEJN,SAAU,6BAAY,CACtBC,SAAU,CACNM,cAAe"} \ No newline at end of file diff --git a/amd/build/page-result-overview.min.js b/amd/build/page-result-overview.min.js index e836f07..c2af62b 100644 --- a/amd/build/page-result-overview.min.js +++ b/amd/build/page-result-overview.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-result-overview",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-report-components","./report-viewer-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanReportComponents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(studyplanid,pageid,firstperiod,lastperiod){if(void 0===pageid||!Number.isInteger(Number(pageid))||void 0===studyplanid||!Number.isInteger(Number(studyplanid)))return void debug.error("Error: studyplan id and page id not provided as integer numbers to script.",studyplanid,pageid,firstperiod,lastperiod);studyplanid=Number(studyplanid),pageid=Number(pageid);new _vue.default({el:"#root",data:{structure:null,studyplan:null,page:null,text:strings.studyplanReport},created(){this.loadStructure(pageid,firstperiod,lastperiod)},computed:{},methods:{loadStructure(pageid,firstperiod,lastperiod){const self=this;this.structure=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_report_structure",args:{pageid:pageid,firstperiod:firstperiod,lastperiod:lastperiod}}])[0].then((response=>{self.structure=response,self.studyplan=response.studyplan,self.page=response.page})).catch(_notification.default.exception)},selectedPage(e){debug.info("SelectedPage",e);const pageid=e.target.value;this.loadStructure(pageid)},selectedFirstPeriod(e){debug.info("selectedFirstPeriod",e);let f=e.target.value,l=this.structure.lastperiod;l{self.structure=response,self.studyplan=response.studyplan,self.page=response.page})).catch(_notification.default.exception)},selectedPage(e){debug.info("SelectedPage",e);const pageid=e.target.value;this.loadStructure(pageid)},selectedFirstPeriod(e){debug.info("selectedFirstPeriod",e);let f=e.target.value,l=this.structure.lastperiod;l {\n self.structure = response;\n self.studyplan = response.studyplan;\n self.page = response.page;\n return;\n }).catch(notification.exception);\n },\n selectedPage(e) {\n debug.info(\"SelectedPage\", e);\n const pageid = e.target.value;\n this.loadStructure(pageid);\n },\n selectedFirstPeriod(e) {\n debug.info(\"selectedFirstPeriod\", e);\n let f = e.target.value;\n let l = this.structure.lastperiod;\n if (l < f) {\n l = f;\n }\n this.loadStructure(this.page.id, f, l);\n },\n selectedLastPeriod(e) {\n debug.info(\"selectedLastPeriod\", e);\n let f = this.structure.firstperiod;\n let l = e.target.value;\n if (l < f) {\n l = f;\n }\n this.loadStructure(this.page.id, f, l);\n\n },\n },\n });\n}\n"],"names":["studyplanid","pageid","firstperiod","lastperiod","undefined","Number","isInteger","debug","error","Vue","el","data","structure","studyplan","page","text","strings","studyplanReport","created","loadStructure","computed","methods","self","this","methodname","args","then","response","catch","notification","exception","selectedPage","e","info","target","value","selectedFirstPeriod","f","l","id","selectedLastPeriod","use","SRComponents","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","periods","period","loading","all","from","to"],"mappings":"gmBAkDqBA,YAAaC,OAAQC,YAAaC,oBAC/CC,IAAcH,SAAWI,OAAOC,UAAUD,OAAOJ,eACjDG,IAAcJ,cAAgBK,OAAOC,UAAUD,OAAOL,0BACtDO,MAAMC,MAAM,6EACRR,YAAaC,OAAQC,YAAaC,YAI1CH,YAAcK,OAAOL,aACrBC,OAASI,OAAOJ,QAGJ,IAAIQ,aAAI,CAChBC,GAAI,QACJC,KAAM,CACFC,UAAW,KACXC,UAAW,KACXC,KAAM,KACNC,KAAMC,QAAQC,iBAElBC,eAESC,cAAclB,OAAQC,YAAaC,aAE5CiB,SAAU,GAGVC,QAAS,CACLF,cAAclB,OAAQC,YAAaC,kBACzBmB,KAAOC,UACRX,UAAY,oBACZ,CAAC,CACFY,WAAY,2CACZC,KAAM,CAACxB,OAAQA,OACXC,YAAaA,YACbC,WAAYA,eAEhB,GAAGuB,MAAMC,WACTL,KAAKV,UAAYe,SACjBL,KAAKT,UAAYc,SAASd,UAC1BS,KAAKR,KAAOa,SAASb,QAEtBc,MAAMC,sBAAaC,YAE1BC,aAAaC,GACTzB,MAAM0B,KAAK,eAAgBD,SACrB/B,OAAS+B,EAAEE,OAAOC,WACnBhB,cAAclB,SAEvBmC,oBAAoBJ,GAChBzB,MAAM0B,KAAK,sBAAuBD,OAC9BK,EAAIL,EAAEE,OAAOC,MACbG,EAAIf,KAAKX,UAAUT,WACnBmC,EAAID,IACJC,EAAID,QAEHlB,cAAcI,KAAKT,KAAKyB,GAAIF,EAAGC,IAExCE,mBAAmBR,GACfzB,MAAM0B,KAAK,qBAAsBD,OAC7BK,EAAId,KAAKX,UAAUV,YACnBoC,EAAIN,EAAEE,OAAOC,MACbG,EAAID,IACJC,EAAID,QAEHlB,cAAcI,KAAKT,KAAKyB,GAAIF,EAAGC,mcApGhDG,IAAIC,iDAEJD,IAAIE,8CAGJF,IAAIG,oCAGJH,IAAII,iCAEJJ,IAAIK,2BAGJvC,MAAQ,IAAIwC,kBAAS,uBAErB/B,SAAU,6BAAY,CACtBC,gBAAiB,CACbJ,UAAW,YACXC,KAAM,gBACNkC,QAAS,UACTC,OAAQ,SACRC,QAAS,eACTC,IAAK,WACLC,KAAM,YACNC,GAAI"} \ No newline at end of file +{"version":3,"file":"page-result-overview.min.js","sources":["../src/page-result-overview.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\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {loadStrings} from './util/string-helper';\n\nimport SRComponents from './studyplan-report-components';\nVue.use(SRComponents);\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\n\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\nlet debug = new Debugger(\"treestudyplanviewer\");\n\nlet strings = loadStrings({\n studyplanReport: {\n studyplan: 'studyplan',\n page: 'studyplanpage',\n periods: 'periods',\n period: 'period',\n loading: 'loading@core',\n all: 'all@core',\n from: 'from@core',\n to: 'to@core',\n },\n});\n\n/**\n * Initialize the Page\n * @param {Number} studyplanid The id of the studyplan we need to view \n * @param {Number} pageid The id of the studyplan page we need to view \n * @param {string} contextname The name of the current context\n * @param {string} studyplanname The name of the current studyplan\n * @param {string} pagename The name of the current page\n * @param {Number} firstperiod The number of the first period to view\n * @param {Number} lastperiod The number of the last period to view \n */\nexport function init(studyplanid, pageid, contextname, studyplanname, \n pagename, firstperiod, lastperiod) {\n if (undefined === pageid || !Number.isInteger(Number(pageid)) ||\n undefined === studyplanid || !Number.isInteger(Number(studyplanid))) {\n debug.error(\"Error: studyplan id and page id not provided as integer numbers to script.\",\n studyplanid, pageid, firstperiod, lastperiod);\n return; // Do not continue if plan and page are not proper integers\n }\n // Ensure a numeric value instead of string.\n studyplanid = Number(studyplanid);\n pageid = Number(pageid);\n\n // Startup app.\n const app = new Vue({\n el: '#root',\n data: {\n structure: null,\n studyplan: null,\n page: null,\n text: strings.studyplanReport,\n contextname: contextname,\n studyplanname: studyplanname,\n pagename: pagename,\n },\n created() {\n // On creation, load the page as specified\n this.loadStructure(pageid, firstperiod, lastperiod);\n },\n methods: {\n loadStructure(pageid, firstperiod, lastperiod) {\n const self = this;\n this.structure = null; // Starts loading icon. Hides old data.\n call([{\n methodname: 'local_treestudyplan_get_report_structure',\n args: {pageid: pageid,\n firstperiod: firstperiod,\n lastperiod: lastperiod\n }\n }])[0].then((response) => {\n self.structure = response;\n self.studyplan = response.studyplan;\n self.page = response.page;\n return;\n }).catch(notification.exception);\n },\n selectedPage(e) {\n debug.info(\"SelectedPage\", e);\n const pageid = e.target.value;\n this.loadStructure(pageid);\n },\n selectedFirstPeriod(e) {\n debug.info(\"selectedFirstPeriod\", e);\n let f = e.target.value;\n let l = this.structure.lastperiod;\n if (l < f) {\n l = f;\n }\n this.loadStructure(this.page.id, f, l);\n },\n selectedLastPeriod(e) {\n debug.info(\"selectedLastPeriod\", e);\n let f = this.structure.firstperiod;\n let l = e.target.value;\n if (l < f) {\n l = f;\n }\n this.loadStructure(this.page.id, f, l);\n\n },\n },\n });\n}\n"],"names":["studyplanid","pageid","contextname","studyplanname","pagename","firstperiod","lastperiod","undefined","Number","isInteger","debug","error","Vue","el","data","structure","studyplan","page","text","strings","studyplanReport","created","loadStructure","methods","self","this","methodname","args","then","response","catch","notification","exception","selectedPage","e","info","target","value","selectedFirstPeriod","f","l","id","selectedLastPeriod","use","SRComponents","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","periods","period","loading","all","from","to"],"mappings":"gmBAoDqBA,YAAaC,OAAQC,YAAaC,cAClCC,SAAUC,YAAaC,oBACpCC,IAAcN,SAAWO,OAAOC,UAAUD,OAAOP,eACjDM,IAAcP,cAAgBQ,OAAOC,UAAUD,OAAOR,0BACtDU,MAAMC,MAAM,6EACRX,YAAaC,OAAQI,YAAaC,YAI1CN,YAAcQ,OAAOR,aACrBC,OAASO,OAAOP,QAGJ,IAAIW,aAAI,CAChBC,GAAI,QACJC,KAAM,CACFC,UAAW,KACXC,UAAW,KACXC,KAAM,KACNC,KAAMC,QAAQC,gBACdlB,YAAaA,YACbC,cAAeA,cACfC,SAAUA,UAEdiB,eAESC,cAAcrB,OAAQI,YAAaC,aAE5CiB,QAAS,CACLD,cAAcrB,OAAQI,YAAaC,kBACzBkB,KAAOC,UACRV,UAAY,oBACZ,CAAC,CACFW,WAAY,2CACZC,KAAM,CAAC1B,OAAQA,OACXI,YAAaA,YACbC,WAAYA,eAEhB,GAAGsB,MAAMC,WACTL,KAAKT,UAAYc,SACjBL,KAAKR,UAAYa,SAASb,UAC1BQ,KAAKP,KAAOY,SAASZ,QAEtBa,MAAMC,sBAAaC,YAE1BC,aAAaC,GACTxB,MAAMyB,KAAK,eAAgBD,SACrBjC,OAASiC,EAAEE,OAAOC,WACnBf,cAAcrB,SAEvBqC,oBAAoBJ,GAChBxB,MAAMyB,KAAK,sBAAuBD,OAC9BK,EAAIL,EAAEE,OAAOC,MACbG,EAAIf,KAAKV,UAAUT,WACnBkC,EAAID,IACJC,EAAID,QAEHjB,cAAcG,KAAKR,KAAKwB,GAAIF,EAAGC,IAExCE,mBAAmBR,GACfxB,MAAMyB,KAAK,qBAAsBD,OAC7BK,EAAId,KAAKV,UAAUV,YACnBmC,EAAIN,EAAEE,OAAOC,MACbG,EAAID,IACJC,EAAID,QAEHjB,cAAcG,KAAKR,KAAKwB,GAAIF,EAAGC,mcAvGhDG,IAAIC,iDAEJD,IAAIE,8CAGJF,IAAIG,oCAGJH,IAAII,iCAEJJ,IAAIK,2BAEJtC,MAAQ,IAAIuC,kBAAS,uBAErB9B,SAAU,6BAAY,CACtBC,gBAAiB,CACbJ,UAAW,YACXC,KAAM,gBACNiC,QAAS,UACTC,OAAQ,SACRC,QAAS,eACTC,IAAK,WACLC,KAAM,YACNC,GAAI"} \ 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 c1d3441..462af46 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","./util/browserbuttonevents","./report-viewer-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_browserbuttonevents,_reportViewerComponents,_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:{selected:{planid:0,studentid:0},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].then((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&&""!=parts[0])for(let idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1]);break}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_available_categories",args:{operation:"view",refcontext_id:contextid}}])[0].then((response=>{const contexts=[];for(const ix in response){const cat=response[ix];(cat.studyplancount>0||cat.context_id==contextid)&&contexts.push(cat)}app.usedcontexts=contexts})).catch(_notification.default.exception),(0,_browserbuttonevents.addBrowserButtonEvent)(this.navChanged,this.navChanged)},computed:{dropdownTitle(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplanSelectPlaceholder},contextid:()=>contextid},methods:{navChanged(){const hash=window.location.hash.replace("#",""),parts=hash.split("-");if(debug.log("Navigation changed",hash,parts),parts&&parts.length>0){const planid=Number(parts[0]),studentid=parts.length>1?Number(parts[1]):0;if(debug.log("Selected ids",planid,studentid,this.selected.planid,this.selected.studentid),0==planid)planid!=this.selected.planid&&this.closeStudyplan(!1);else if(this.selected.planid!=planid||0==studentid&&0!=this.selected.studentid){debug.info("Requested plan changed - loading studyplan");for(let idx in app.studyplans){const plan=this.studyplans[idx];if(Number(plan.id)==planid){this.selectStudyplan(plan,studentid,!1);break}}}else if(this.selected.studentid!=studentid)for(const group of app.associatedstudents)for(const student of group.users)if(Number(student.id)==studentid){app.showStudentView(student,!1);break}}},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)},closeStudyplan(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];app.selected.planid=0,app.selected.studentid=0,app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,updatehash&&(window.location.hash="")},selectStudyplan(studyplan,studentid){let updatehash=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];app.selected.planid=Number(studyplan.id),app.selected.studentid=studentid?Number(studentid):0,app.loadingstudyplan=!0,app.associatedstudents=[],app.selectedstudent=null,app.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].then((response=>{app.activestudyplan=(0,_studyplanProcessor.processStudyplan)(response,!0),(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated_grouped",args:{studyplan_id:studyplan.id}}])[0].then((response=>{app.associatedstudents=response;let foundstudent=!1;if(studentid)for(const group of app.associatedstudents)for(const student of group.users)if(student.id==studentid){foundstudent=!0,app.showStudentView(student,updatehash);break}foundstudent||(app.selected.studentid=0,updatehash&&(window.location.hash=app.activestudyplan.id),app.displayedstudyplan=app.activestudyplan,app.loadingstudyplan=!1)})).catch(_notification.default.exception)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){let updatehash=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];app.selected.studentid=student?Number(student.id):0,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.selected.planid}}])[0].then((response=>{app.studentstudyplan=(0,_studyplanProcessor.processStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,updatehash&&(window.location.hash=app.activestudyplan.id+"-"+student.id)})).catch((error=>{_notification.default.exception(error),app.loadingstudyplan=!1}))):this.showOverview(updatehash)},showOverview(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];app.selected.studentid=0,app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,updatehash&&(window.location.hash=app.activestudyplan.id)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_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);let debug=new _debugger.default("treestudyplanviewer"),strings=(0,_stringHelper.loadStrings)({studyplan:{studyplanSelectPlaceholder:"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","./util/browserbuttonevents","./report-viewer-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_browserbuttonevents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid,contextname){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:{selected:{planid:0,studentid:0},displayedstudyplan:null,activestudyplan:null,associatedstudents:[],selectedstudent:null,studentstudyplan:null,loadingstudyplan:!1,studyplans:[],text:strings.studyplan,toolbox:{right:!0},usedcontexts:[],contextname:contextname},async mounted(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].then((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&&""!=parts[0])for(let idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1]);break}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_available_categories",args:{operation:"view",refcontext_id:contextid}}])[0].then((response=>{const contexts=[];for(const ix in response){const cat=response[ix];(cat.studyplancount>0||cat.context_id==contextid)&&contexts.push(cat)}app.usedcontexts=contexts})).catch(_notification.default.exception),(0,_browserbuttonevents.addBrowserButtonEvent)(this.navChanged,this.navChanged)},computed:{dropdownTitle(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplanSelectPlaceholder},contextid:()=>contextid},methods:{navChanged(){const hash=window.location.hash.replace("#",""),parts=hash.split("-");if(debug.log("Navigation changed",hash,parts),parts&&parts.length>0){const planid=Number(parts[0]),studentid=parts.length>1?Number(parts[1]):0;if(debug.log("Selected ids",planid,studentid,this.selected.planid,this.selected.studentid),0==planid)planid!=this.selected.planid&&this.closeStudyplan(!1);else if(this.selected.planid!=planid||0==studentid&&0!=this.selected.studentid){debug.info("Requested plan changed - loading studyplan");for(let idx in app.studyplans){const plan=this.studyplans[idx];if(Number(plan.id)==planid){this.selectStudyplan(plan,studentid,!1);break}}}else if(this.selected.studentid!=studentid)for(const group of app.associatedstudents)for(const student of group.users)if(Number(student.id)==studentid){app.showStudentView(student,!1);break}}},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)},closeStudyplan(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];app.selected.planid=0,app.selected.studentid=0,app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,updatehash&&(window.location.hash="")},selectStudyplan(studyplan,studentid){let updatehash=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];app.selected.planid=Number(studyplan.id),app.selected.studentid=studentid?Number(studentid):0,app.loadingstudyplan=!0,app.associatedstudents=[],app.selectedstudent=null,app.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].then((response=>{app.activestudyplan=(0,_studyplanProcessor.processStudyplan)(response,!0),(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated_grouped",args:{studyplan_id:studyplan.id}}])[0].then((response=>{app.associatedstudents=response;let foundstudent=!1;if(studentid)for(const group of app.associatedstudents)for(const student of group.users)if(student.id==studentid){foundstudent=!0,app.showStudentView(student,updatehash);break}foundstudent||(app.selected.studentid=0,updatehash&&(window.location.hash=app.activestudyplan.id),app.displayedstudyplan=app.activestudyplan,app.loadingstudyplan=!1)})).catch(_notification.default.exception)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){let updatehash=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];app.selected.studentid=student?Number(student.id):0,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.selected.planid}}])[0].then((response=>{app.studentstudyplan=(0,_studyplanProcessor.processStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,updatehash&&(window.location.hash=app.activestudyplan.id+"-"+student.id)})).catch((error=>{_notification.default.exception(error),app.loadingstudyplan=!1}))):this.showOverview(updatehash)},showOverview(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];app.selected.studentid=0,app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,updatehash&&(window.location.hash=app.activestudyplan.id)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_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);let debug=new _debugger.default("treestudyplanviewer"),strings=(0,_stringHelper.loadStrings)({studyplan:{studyplanSelectPlaceholder:"studyplan_select_placeholder",loading:"loading@core",back:"back",studyplanSelect:"studyplan_select",selectstudentBtn:"selectstudent_btn",studyplanNoneselected:"studyplan_noneselected",showoverview:"showoverview"}})})); //# 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 01b86ed..3502020 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-unused-vars: \"off\" */\n/* eslint no-trailing-spaces: \"off\" */\n/* eslint promise/no-nesting: \"off\" */\n/* eslint max-depth: [\"error\", 5] */\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 {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\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 = loadStrings({\n studyplan: {\n studyplanSelectPlaceholder: 'studyplan_select_placeholder',\n },\n});\n\n/**\n * Initialize the Page\n * @param {number} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {number} 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) {\n contextid = 1;\n } else { // Ensure a numeric value instead of string\n contextid = Number(contextid);\n }\n if (undefined === categoryid || !Number.isInteger(Number(categoryid))) {\n categoryid = 0;\n } else { // Ensure a numeric value instead of string\n categoryid = Number(categoryid);\n }\n\n let app = new Vue({\n el: '#root',\n data: {\n selected: {\n planid: 0,\n studentid: 0,\n },\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].then((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 } 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 && parts[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 return;\n }).catch(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_available_categories',\n args: {operation: 'view', 'refcontext_id': contextid}\n }])[0].then((response) => {\n const contexts = [];\n for (const ix in response) {\n const cat = response[ix];\n if (cat.studyplancount > 0 || cat.context_id == contextid) {\n contexts.push(cat);\n }\n }\n app.usedcontexts = contexts;\n return;\n }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\n dropdownTitle() {\n if (this.activestudyplan && this.activestudyplan.name) {\n return this.activestudyplan.name;\n } else {\n return this.text.studyplanSelectPlaceholder;\n }\n },\n contextid() {\n return contextid;\n }\n },\n methods: {\n navChanged() {\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n debug.log(\"Navigation changed\", hash, parts);\n\n if (!!parts && parts.length > 0) {\n const planid = Number(parts[0]);\n const studentid = (parts.length > 1) ? Number(parts[1]) : 0;\n\n debug.log(\"Selected ids\", planid, studentid, this.selected.planid, this.selected.studentid);\n if (planid == 0) {\n if (planid != this.selected.planid) {\n this.closeStudyplan(false);\n }\n } else if (this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0)) {\n debug.info(\"Requested plan changed - loading studyplan\");\n for (let idx in app.studyplans) {\n const plan = this.studyplans[idx];\n if (Number(plan.id) == planid) {\n this.selectStudyplan(plan, studentid, false);\n break;\n }\n }\n } else if (this.selected.studentid != studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (Number(student.id) == studentid) {\n app.showStudentView(student, false);\n break;\n }\n }\n }\n }\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 closeStudyplan(updatehash = true) {\n app.selected.planid = 0;\n app.selected.studentid = 0;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n if (updatehash) {\n window.location.hash = '';\n }\n },\n\n selectStudyplan(studyplan, studentid, updatehash = true) {\n app.selected.planid = Number(studyplan.id);\n app.selected.studentid = studentid ? Number(studentid) : 0;\n // Fetch studyplan\n app.loadingstudyplan = true;\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].then((response) => {\n app.activestudyplan = processStudyplan(response, true);\n \n call([{\n methodname: 'local_treestudyplan_all_associated_grouped',\n args: {'studyplan_id': studyplan.id}\n }])[0].then((response) => {\n app.associatedstudents = response;\n let foundstudent = false;\n if (studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (student.id == studentid) {\n foundstudent = true;\n app.showStudentView(student, updatehash);\n break;\n }\n }\n }\n }\n if (!foundstudent) {\n app.selected.studentid = 0;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n app.displayedstudyplan = app.activestudyplan;\n app.loadingstudyplan = false;\n }\n return;\n }).catch(notification.exception);\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student, updatehash = true) {\n app.selected.studentid = student ? Number(student.id) : 0;\n if (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.selected.planid}\n }])[0].then((response) => {\n app.studentstudyplan = processStudyplan(response, false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }\n return;\n }).catch((error) => {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n } else {\n this.showOverview(updatehash);\n }\n },\n showOverview(updatehash = true) {\n app.selected.studentid = 0;\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n }\n\n },\n });\n}\n"],"names":["contextid","categoryid","undefined","Number","isInteger","app","Vue","el","data","selected","planid","studentid","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","studyplan","toolbox","right","usedcontexts","methodname","args","then","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","catch","notification","exception","operation","contexts","ix","cat","studyplancount","context_id","push","this","navChanged","computed","dropdownTitle","studyplanSelectPlaceholder","methods","debug","log","closeStudyplan","info","plan","group","student","users","showStudentView","switchContext","ctxid","params","URLSearchParams","search","delete","set","setTimeout","href","pathname","toString","updatehash","foundstudent","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"8pBA0CqBA,UAAWC,YAGxBD,eADAE,IAAcF,YAAcG,OAAOC,UAAUD,OAAOH,aAAeA,UAAY,EACnE,EAEAG,OAAOH,WAKnBC,gBAHAC,IAAcD,YAAeE,OAAOC,UAAUD,OAAOF,aAGxCE,OAAOF,YAFP,MAKbI,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,SAAU,CACNC,OAAQ,EACRC,UAAW,GAEfC,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,YAAe1B,cACrB,GAAG2B,MAAMC,iBACHC,UAAY,CAACC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GAChDJ,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EJD,IAAIE,oCAGJF,IAAIG,iCAEJH,IAAII,2BAGJ9B,MAAQ,IAAI+B,kBAAS,uBAErB9E,SAAU,6BAAY,CACtBC,UAAW,CACP4C,2BAA4B"} \ No newline at end of file +{"version":3,"file":"page-view-plan.min.js","sources":["../src/page-view-plan.js"],"sourcesContent":["/* eslint no-unused-vars: \"off\" */\n/* eslint no-trailing-spaces: \"off\" */\n/* eslint promise/no-nesting: \"off\" */\n/* eslint max-depth: [\"error\", 5] */\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 {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\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 = loadStrings({\n studyplan: {\n studyplanSelectPlaceholder: 'studyplan_select_placeholder',\n loading: \"loading@core\",\n back: \"back\",\n studyplanSelect: \"studyplan_select\",\n selectstudentBtn: \"selectstudent_btn\",\n studyplanNoneselected: \"studyplan_noneselected\",\n showoverview: \"showoverview\"\n },\n});\n\n/**\n * Initialize the Page\n * @param {number} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {number} categoryid The category we shoud attempt to work in (1:1 related to the context)\n * @param {string} contextname Name of the current context\n */\nexport function init(contextid, categoryid, contextname) {\n // Make sure the id's are numeric and integer\n if (undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1) {\n contextid = 1;\n } else { // Ensure a numeric value instead of string\n contextid = Number(contextid);\n }\n if (undefined === categoryid || !Number.isInteger(Number(categoryid))) {\n categoryid = 0;\n } else { // Ensure a numeric value instead of string\n categoryid = Number(categoryid);\n }\n\n let app = new Vue({\n el: '#root',\n data: {\n selected: {\n planid: 0,\n studentid: 0,\n },\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 contextname: contextname\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: {'context_id': contextid}\n }])[0].then((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 } 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 && parts[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 return;\n }).catch(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_available_categories',\n args: {operation: 'view', 'refcontext_id': contextid}\n }])[0].then((response) => {\n const contexts = [];\n for (const ix in response) {\n const cat = response[ix];\n if (cat.studyplancount > 0 || cat.context_id == contextid) {\n contexts.push(cat);\n }\n }\n app.usedcontexts = contexts;\n return;\n }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\n dropdownTitle() {\n if (this.activestudyplan && this.activestudyplan.name) {\n return this.activestudyplan.name;\n } else {\n return this.text.studyplanSelectPlaceholder;\n }\n },\n contextid() {\n return contextid;\n }\n },\n methods: {\n navChanged() {\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n debug.log(\"Navigation changed\", hash, parts);\n\n if (!!parts && parts.length > 0) {\n const planid = Number(parts[0]);\n const studentid = (parts.length > 1) ? Number(parts[1]) : 0;\n\n debug.log(\"Selected ids\", planid, studentid, this.selected.planid, this.selected.studentid);\n if (planid == 0) {\n if (planid != this.selected.planid) {\n this.closeStudyplan(false);\n }\n } else if (this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0)) {\n debug.info(\"Requested plan changed - loading studyplan\");\n for (let idx in app.studyplans) {\n const plan = this.studyplans[idx];\n if (Number(plan.id) == planid) {\n this.selectStudyplan(plan, studentid, false);\n break;\n }\n }\n } else if (this.selected.studentid != studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (Number(student.id) == studentid) {\n app.showStudentView(student, false);\n break;\n }\n }\n }\n }\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 closeStudyplan(updatehash = true) {\n app.selected.planid = 0;\n app.selected.studentid = 0;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n if (updatehash) {\n window.location.hash = '';\n }\n },\n\n selectStudyplan(studyplan, studentid, updatehash = true) {\n app.selected.planid = Number(studyplan.id);\n app.selected.studentid = studentid ? Number(studentid) : 0;\n // Fetch studyplan\n app.loadingstudyplan = true;\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].then((response) => {\n app.activestudyplan = processStudyplan(response, true);\n \n call([{\n methodname: 'local_treestudyplan_all_associated_grouped',\n args: {'studyplan_id': studyplan.id}\n }])[0].then((response) => {\n app.associatedstudents = response;\n let foundstudent = false;\n if (studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (student.id == studentid) {\n foundstudent = true;\n app.showStudentView(student, updatehash);\n break;\n }\n }\n }\n }\n if (!foundstudent) {\n app.selected.studentid = 0;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n app.displayedstudyplan = app.activestudyplan;\n app.loadingstudyplan = false;\n }\n return;\n }).catch(notification.exception);\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student, updatehash = true) {\n app.selected.studentid = student ? Number(student.id) : 0;\n if (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.selected.planid}\n }])[0].then((response) => {\n app.studentstudyplan = processStudyplan(response, false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }\n return;\n }).catch((error) => {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n } else {\n this.showOverview(updatehash);\n }\n },\n showOverview(updatehash = true) {\n app.selected.studentid = 0;\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n }\n\n },\n });\n}\n"],"names":["contextid","categoryid","contextname","undefined","Number","isInteger","app","Vue","el","data","selected","planid","studentid","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","studyplan","toolbox","right","usedcontexts","methodname","args","then","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","catch","notification","exception","operation","contexts","ix","cat","studyplancount","context_id","push","this","navChanged","computed","dropdownTitle","studyplanSelectPlaceholder","methods","debug","log","closeStudyplan","info","plan","group","student","users","showStudentView","switchContext","ctxid","params","URLSearchParams","search","delete","set","setTimeout","href","pathname","toString","updatehash","foundstudent","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","loading","back","studyplanSelect","selectstudentBtn","studyplanNoneselected","showoverview"],"mappings":"8pBAiDqBA,UAAWC,WAAYC,aAGpCF,eADAG,IAAcH,YAAcI,OAAOC,UAAUD,OAAOJ,aAAeA,UAAY,EACnE,EAEAI,OAAOJ,WAKnBC,gBAHAE,IAAcF,YAAeG,OAAOC,UAAUD,OAAOH,aAGxCG,OAAOH,YAFP,MAKbK,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,SAAU,CACNC,OAAQ,EACRC,UAAW,GAEfC,mBAAoB,KACpBC,gBAAiB,KACjBC,mBAAoB,GACpBC,gBAAiB,KACjBC,iBAAkB,KAClBC,kBAAkB,EAClBC,WAAY,GACZC,KAAMC,QAAQC,UACdC,QAAS,CACLC,OAAO,GAEXC,aAAc,GACdvB,YAAaA,4CAGR,CAAC,CACFwB,WAAY,sCACZC,KAAM,YAAe3B,cACrB,GAAG4B,MAAMC,iBACHC,UAAY,CAACC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GAChDJ,SAASK,MAAK,CAACC,EAAGC,WACRC,SAAU,+BAAgBF,GAC1BG,SAAU,+BAAgBF,GAE1BG,EAAIT,UAAUO,SAAWP,UAAUQ,gBAChC,GAALC,EAEOJ,EAAEK,KAAKC,cAAcL,EAAEI,MAEvBD,KAGfjC,IAAIa,WAAaU,eAGXa,MADOC,OAAOC,SAASC,KAAKC,QAAQ,IAAK,IAC5BC,MAAM,QAEnBL,OAASA,MAAMM,OAAS,GAAiB,IAAZN,MAAM,OAChC,IAAIO,OAAO3C,IAAIa,cACZb,IAAIa,WAAW8B,KAAKC,IAAMR,MAAM,GAAI,CACpCpC,IAAI6C,gBAAgB7C,IAAIa,WAAW8B,KAAMP,MAAM,cAM5DU,MAAMC,sBAAaC,0BACjB,CAAC,CACF5B,WAAY,gDACZC,KAAM,CAAC4B,UAA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BF,aAASc,sEACrBlF,IAAII,SAASE,UAAY8D,QAAUtE,OAAOsE,QAAQxB,IAAM,EACpDwB,SACApE,IAAIU,gBAAkB0D,QACtBpE,IAAIW,iBAAmB,KACvBX,IAAIY,kBAAmB,iBAClB,CAAC,CACFQ,WAAY,yCACZC,KAAM,CAACgE,OAAQjB,QAAQxB,GAAI0C,YAAatF,IAAII,SAASC,WACrD,GAAGiB,MAAMC,WACTvB,IAAIW,kBAAmB,wCAAiBY,UAAU,GAClDvB,IAAIO,mBAAqBP,IAAIW,iBAC7BX,IAAIY,kBAAmB,EACnBsE,aACA7C,OAAOC,SAASC,KAAOvC,IAAIQ,gBAAgBoC,GAAK,IAAMwB,QAAQxB,OAGnEE,OAAOsC,8BACOpC,UAAUoC,OACvBpF,IAAIY,kBAAmB,CAAvB,UAGC2E,aAAaL,aAG1BK,mBAAaL,sEACTlF,IAAII,SAASE,UAAY,EACzBN,IAAIU,gBAAkB,KACtBV,IAAIW,iBAAmB,KACvBX,IAAIO,mBAAqBP,IAAIQ,gBACzB0E,aACA7C,OAAOC,SAASC,KAAOvC,IAAIQ,gBAAgBoC,sXApQ3D4C,IAAIC,8CAEJD,IAAIE,oCAGJF,IAAIG,iCAEJH,IAAII,2BAGJ9B,MAAQ,IAAI+B,kBAAS,uBAErB9E,SAAU,6BAAY,CACtBC,UAAW,CACP4C,2BAA4B,+BAC5BkC,QAAS,eACTC,KAAM,OACNC,gBAAiB,mBACjBC,iBAAkB,oBAClBC,sBAAuB,yBACvBC,aAAc"} \ No newline at end of file diff --git a/amd/src/page-coach.js b/amd/src/page-coach.js index 7f9cdfb..9648d7d 100644 --- a/amd/src/page-coach.js +++ b/amd/src/page-coach.js @@ -41,6 +41,10 @@ let debug = new Debugger("treestudyplancoach"); let strings = loadStrings({ coach: { + back: "back", + selectstudentBtn: "selectstudent_btn", + coacheditmode: "coacheditmode", + showoverview: "showoverview", }, }); diff --git a/amd/src/page-edit-plan.js b/amd/src/page-edit-plan.js index dc59099..d90da12 100644 --- a/amd/src/page-edit-plan.js +++ b/amd/src/page-edit-plan.js @@ -55,6 +55,11 @@ let strings = loadStrings({ 'advanced_import_from_file': 'advanced_import_from_file', 'advanced_create_from_template': 'advanced_create_from_template', 'studyplan_add': "studyplan_add", + 'loading': "loading@core", + 'back': "back", + 'studyplanSelect': "studyplan_select", + 'defaultaggregation': "defaultaggregation", + 'studyplanNoneselected': "studyplan_noneselected", }, }); @@ -62,9 +67,10 @@ let strings = loadStrings({ * Initialize the Page * @param {int} contextid The context we should attempt to work in (1:1 related to the category) * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context) + * @param {string} contextname Name of the current context * @param {object} options Options to be passed to this script */ -export function init(contextid, categoryid, options) { +export function init(contextid, categoryid, contextname, options) { // Make sure the id's are numeric and integer if (undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1) { contextid = 1; @@ -111,7 +117,7 @@ export function init(contextid, categoryid, options) { loadingstudyplan: false, studyplans: [], templatecount: 0, - + contextname: contextname, text: strings.studyplan, usedcontexts: [], }, diff --git a/amd/src/page-myreport.js b/amd/src/page-myreport.js index 567b27d..2aa2047 100644 --- a/amd/src/page-myreport.js +++ b/amd/src/page-myreport.js @@ -5,30 +5,40 @@ import Vue from './vue/vue'; +import {loadStrings} from './util/string-helper'; + import RVComponents from './report-viewer-components'; Vue.use(RVComponents); - import PortalVue from './portal-vue/portal-vue.esm'; Vue.use(PortalVue); import BootstrapVue from './bootstrap-vue/bootstrap-vue'; +import { settings } from './util/settings'; Vue.use(BootstrapVue); +let strings = loadStrings({ + myreport: { + manageInvites: "manage_invites", + }, +}); + /** * Initialize the Page * @param {string} type Type of page to show - * @param {Object} arg1 Argument1 as passed + * @param {Object} key Invitekey or userid of another user + * @param {boolean} enableplansharing True if studyplan sharing is enabled */ - export function init(type = "own", arg1) { + export function init(type = "own", key, enableplansharing) { let app = new Vue({ el: '#root', data: { - "studyplans": [], - "type": type, - "invitekey": (type == "invited") ? arg1 : null, - "userid": (type == "other") ? arg1 : null, + studyplans: [], + type: type, + invitekey: (type == "invited") ? key : null, + userid: (type == "other") ? key : null, + text: strings.myreport, + enableplansharing: enableplansharing, }, methods: { - }, }); diff --git a/amd/src/page-result-overview.js b/amd/src/page-result-overview.js index 1245e36..424a433 100644 --- a/amd/src/page-result-overview.js +++ b/amd/src/page-result-overview.js @@ -25,7 +25,6 @@ Vue.use(PortalVue); import BootstrapVue from './bootstrap-vue/bootstrap-vue'; Vue.use(BootstrapVue); - let debug = new Debugger("treestudyplanviewer"); let strings = loadStrings({ @@ -45,10 +44,14 @@ let strings = loadStrings({ * Initialize the Page * @param {Number} studyplanid The id of the studyplan we need to view * @param {Number} pageid The id of the studyplan page we need to view + * @param {string} contextname The name of the current context + * @param {string} studyplanname The name of the current studyplan + * @param {string} pagename The name of the current page * @param {Number} firstperiod The number of the first period to view * @param {Number} lastperiod The number of the last period to view */ -export function init(studyplanid, pageid, firstperiod, lastperiod) { +export function init(studyplanid, pageid, contextname, studyplanname, + pagename, firstperiod, lastperiod) { if (undefined === pageid || !Number.isInteger(Number(pageid)) || undefined === studyplanid || !Number.isInteger(Number(studyplanid))) { debug.error("Error: studyplan id and page id not provided as integer numbers to script.", @@ -67,13 +70,13 @@ export function init(studyplanid, pageid, firstperiod, lastperiod) { studyplan: null, page: null, text: strings.studyplanReport, + contextname: contextname, + studyplanname: studyplanname, + pagename: pagename, }, created() { // On creation, load the page as specified this.loadStructure(pageid, firstperiod, lastperiod); - }, - computed: { - }, methods: { loadStructure(pageid, firstperiod, lastperiod) { diff --git a/amd/src/page-view-plan.js b/amd/src/page-view-plan.js index b6f557e..46eba6a 100644 --- a/amd/src/page-view-plan.js +++ b/amd/src/page-view-plan.js @@ -32,6 +32,12 @@ let debug = new Debugger("treestudyplanviewer"); let strings = loadStrings({ studyplan: { studyplanSelectPlaceholder: 'studyplan_select_placeholder', + loading: "loading@core", + back: "back", + studyplanSelect: "studyplan_select", + selectstudentBtn: "selectstudent_btn", + studyplanNoneselected: "studyplan_noneselected", + showoverview: "showoverview" }, }); @@ -39,8 +45,9 @@ let strings = loadStrings({ * Initialize the Page * @param {number} contextid The context we should attempt to work in (1:1 related to the category) * @param {number} categoryid The category we shoud attempt to work in (1:1 related to the context) + * @param {string} contextname Name of the current context */ -export function init(contextid, categoryid) { +export function init(contextid, categoryid, contextname) { // Make sure the id's are numeric and integer if (undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1) { contextid = 1; @@ -72,6 +79,7 @@ export function init(contextid, categoryid) { right: true, }, usedcontexts: [], + contextname: contextname }, async mounted() { call([{ diff --git a/coach.php b/coach.php index 0c0d095..2ae1489 100644 --- a/coach.php +++ b/coach.php @@ -48,5 +48,5 @@ if ($CFG->debugdeveloper) { $PAGE->requires->js_call_amd('local_treestudyplan/page-coach', 'init', []); print $OUTPUT->header(); -print $OUTPUT->render_from_template('local_treestudyplan/edit_plan', []); +print $OUTPUT->render_from_template('local_treestudyplan/coach', []); print $OUTPUT->footer(); diff --git a/edit-plan.php b/edit-plan.php index bb5cec5..b1594d6 100644 --- a/edit-plan.php +++ b/edit-plan.php @@ -108,9 +108,14 @@ $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/boot if ($CFG->debugdeveloper) { $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css')); } -$PAGE->requires->js_call_amd('local_treestudyplan/page-edit-plan', 'init', [$studyplancontext->id, $categoryid, [ - "defaultAggregation" => get_config("local_treestudyplan", "aggregation_mode"), -]]); +$PAGE->requires->js_call_amd('local_treestudyplan/page-edit-plan', 'init', [ + $studyplancontext->id, + $categoryid, + $contextname, + [ + "defaultAggregation" => get_config("local_treestudyplan", "aggregation_mode"), + ] +]); print $OUTPUT->header(); print $OUTPUT->render_from_template('local_treestudyplan/edit_plan', ["contextname" => $contextname]); diff --git a/lang/en/local_treestudyplan.php b/lang/en/local_treestudyplan.php index 8bf3d02..2dc0493 100644 --- a/lang/en/local_treestudyplan.php +++ b/lang/en/local_treestudyplan.php @@ -224,7 +224,7 @@ $string["studyplan_slots"] = 'Number of columns in plan'; $string["studyplan_periods"] = 'Number of periods in plan'; $string["studyplan_startdate"] = 'Start date of plan'; $string["studyplan_enddate"] = 'End date of plan'; -$string["studyplan_noneselected"] = "Pick a study plan to start editing"; +$string["studyplan_noneselected"] = "Pick a study plan"; $string["studyplan_select"] = "Study plan:"; $string["studyplan_select_placeholder"] = "Select study plan"; $string["studyplan_suspend"] = 'Suspend study plan'; diff --git a/myreport.php b/myreport.php index 4f95aed..fc854b8 100644 --- a/myreport.php +++ b/myreport.php @@ -47,17 +47,15 @@ if ($amteaching) { $PAGE->set_heading(get_string('report_invited', 'local_treestudyplan', "{$USER->firstname} {$USER->lastname}")); } +$enableplansharing = get_config("local_treestudyplan", "enableplansharing") && !$amteaching; + // Load javascripts and specific css. $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/bootstrap-vue/bootstrap-vue.css')); if ($CFG->debugdeveloper) { $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css')); } -$PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', [$amteaching ? 'teaching' : 'own']); +$PAGE->requires->js_call_amd('local_treestudyplan/page-myreport', 'init', [$amteaching ? 'teaching' : 'own', null, $enableplansharing]); print $OUTPUT->header(); -$data = new \stdClass; -$data->enableplansharing = get_config("local_treestudyplan", "enableplansharing") && !$amteaching; -$data->teachermode = $amteaching; -print $OUTPUT->render_from_template('local_treestudyplan/myreport', $data); - +print $OUTPUT->render_from_template('local_treestudyplan/myreport', []); print $OUTPUT->footer(); diff --git a/result-overview.php b/result-overview.php index 55d1e59..6bde3bb 100644 --- a/result-overview.php +++ b/result-overview.php @@ -59,7 +59,14 @@ if ($CFG->debugdeveloper) { $PAGE->requires->js_call_amd( 'local_treestudyplan/page-result-overview', 'init', - [$studyplan->id(), $page->id(), $firstperiod, $lastperiod] + [ + $studyplan->id(), + $page->id(), + $contextname, + $studyplan->name(), + $page->fullname(), + $firstperiod, + $lastperiod] ); print $OUTPUT->header(); diff --git a/templates/coach.mustache b/templates/coach.mustache index 29f830d..62bced8 100644 --- a/templates/coach.mustache +++ b/templates/coach.mustache @@ -30,7 +30,6 @@ Example context (json): { - "contextname": "System", } }} {{! Next line replaces mustache double curly braces with << and >> for this template, @@ -46,13 +45,13 @@ so it does not mess up vue double curly braces}}
@@ -74,7 +73,7 @@ so it does not mess up vue double curly braces}}

{{selectedstudent.firstname}} {{selectedstudent.lastname}} - {{displayedstudyplan.name}}

-

<<#str>> showoverview, local_treestudyplan <> - {{displayedstudyplan.name}}

+

{{text.showoverview}} - {{displayedstudyplan.name}}