diff --git a/amd/build/page-coach.min.js b/amd/build/page-coach.min.js index 4ecd6a1..7acaf97 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","./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,_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:{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)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)},computed:{},methods:{closeStudyplan(){app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,window.location.hash=""},selectStudyplan(studyplan,studentid){const self=this;self.loadingstudyplan=!0,self.activestudyplan=null,self.associatedstudents=[],self.selectedstudent=null,self.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].then((function(response){self.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),self.displayedstudyplan=self.activestudyplan,self.loadingstudyplan=!1,window.location.hash=self.activestudyplan.id,(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated_grouped",args:{studyplan_id:studyplan.id}}])[0].then((function(response){if(self.associatedstudents=response,studentid){for(const group of self.associatedstudents)for(const student of group.users)if(student.id==studentid){self.showStudentView(student);break}}else for(const group of self.associatedstudents)for(const student of group.users){self.showStudentView(student);break}})).catch(_notification.default.exception)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){app.selectedstudent=student,app.studentstudyplan=null,student&&(app.loadingstudyplan=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_get_user_studyplan",args:{userid:student.id,studyplanid:app.activestudyplan.id}}])[0].then((function(response){app.studentstudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id+"-"+student.id})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1})))},showOverview(){app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,window.location.hash=app.activestudyplan.id}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_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);new _debugger.default("treestudyplancoach");let strings=(0,_stringHelper.load_strings)({coach:{studyplan_select_placeholder:"studyplan_select_placeholder",switch_coach_editmode:"switch_coach_editmode"}})})); +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:{},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((function(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((function(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.load_strings)({coach:{studyplan_select_placeholder:"studyplan_select_placeholder",switch_coach_editmode:"switch_coach_editmode"}})})); //# 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 17346f8..542c9b6 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-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\n\nimport 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 = load_strings({\n coach: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n switch_coach_editmode: 'switch_coach_editmode',\n },\n});\n\n/**\n * Initialize the Page\n */\nexport function init() {\n let app = new Vue({\n el: '#root',\n data: {\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.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 }\n else {\n return t;\n }\n });\n app.studyplans = response;\n // load studyplan from hash if applicable\n const hash = window.location.hash.replace('#','');\n const parts = hash.split(\"-\");\n\n if(!!parts && parts.length > 0){\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == parts[0]){\n app.selectStudyplan(app.studyplans[idx],parts[1]);\n break;\n }\n }\n }\n }).catch(notification.exception);\n },\n computed: {\n },\n methods: {\n closeStudyplan() {\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n window.location.hash = '';\n },\n\n selectStudyplan(studyplan,studentid){\n // fetch studyplan\n const self = this;\n self.loadingstudyplan = true;\n self.activestudyplan = null;\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(function(response){\n self.activestudyplan = ProcessStudyplan(response,true);\n self.displayedstudyplan = self.activestudyplan;\n self.loadingstudyplan = false;\n window.location.hash = self.activestudyplan.id;\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 if(studentid){\n for(const group of self.associatedstudents) {\n for(const student of group.users){\n if(student.id == studentid){\n self.showStudentView(student);\n break;\n }\n }\n }\n } else {\n // Select first student available.\n for(const group of self.associatedstudents) {\n for(const student of group.users){\n self.showStudentView(student);\n break;\n }\n }\n }\n }).catch(notification.exception);\n\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student){\n app.selectedstudent = student;\n app.studentstudyplan = null;\n if (student) {\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(function(response){\n app.studentstudyplan = ProcessStudyplan(response,false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n }\n },\n showOverview(){\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n window.location.hash = app.activestudyplan.id;\n }\n\n },\n });\n}\n"],"names":["app","Vue","el","data","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","computed","methods","closeStudyplan","studyplan","studentid","self","this","studyplan_id","group","student","users","showStudentView","error","userid","studyplanid","showOverview","use","EditorComponents","TSComponents","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","studyplan_select_placeholder","switch_coach_editmode"],"mappings":"+tBAiDQA,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,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,CAAEC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GACjDJ,SAASK,MAAK,CAACC,EAAEC,WACPC,SAAU,+BAAgBF,GAC1BG,SAAU,+BAAgBF,GAE1BG,EAAIT,UAAUO,SAAWP,UAAUQ,gBACjC,GAALC,EAEQJ,EAAEK,KAAKC,cAAcL,EAAEI,MAGvBD,KAGf/B,IAAIU,WAAaW,eAGXa,MADOC,OAAOC,SAASC,KAAKC,QAAQ,IAAI,IAC3BC,MAAM,QAEpBL,OAASA,MAAMM,OAAS,MACrB,IAAIC,OAAOzC,IAAIU,cACZV,IAAIU,WAAW+B,KAAKC,IAAMR,MAAM,GAAG,CAClClC,IAAI2C,gBAAgB3C,IAAIU,WAAW+B,KAAKP,MAAM,cAK3DU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BAAmB,wCAAiBa,UAAS,GACjDrB,IAAII,mBAAqBJ,IAAIQ,iBAC7BR,IAAIS,kBAAmB,EACvB0B,OAAOC,SAASC,KAAOrC,IAAIK,gBAAgBqC,GAAK,IAAMc,QAAQd,MAC/DE,OAAM,SAASe,6BACDb,UAAUa,OACvB3D,IAAIS,kBAAmB,OAInCqD,eACI9D,IAAIO,gBAAkB,KACtBP,IAAIQ,iBAAmB,KACvBR,IAAII,mBAAqBJ,IAAIK,gBAC7B8B,OAAOC,SAASC,KAAOrC,IAAIK,gBAAgBqC,6gBAjKvDqB,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,8CAGJH,IAAII,oCAGJJ,IAAIK,iCAEJL,IAAIM,uBAGI,IAAIC,kBAAS,0BAErB1D,SAAU,8BAAa,CACvBC,MAAO,CACH0D,6BAA8B,+BAC9BC,sBAAuB"} \ 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-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\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 = load_strings({\n coach: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n switch_coach_editmode: 'switch_coach_editmode',\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 }\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 }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\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(function(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) { // 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 }).catch(notification.exception);\n\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(function(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 }).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","methods","debug","log","Number","closeStudyplan","info","plan","group","student","users","showStudentView","updatehash","studyplan","self","studyplan_id","foundstudent","error","userid","studyplanid","showOverview","use","EditorComponents","TSComponents","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","studyplan_select_placeholder","switch_coach_editmode"],"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,KA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3D,mBAAqB2D,KAAK1D,gBAC/B0D,KAAKtD,kBAAmB,MAE7BmC,MAAMC,sBAAaC,cAEvBF,OAAM,SAASsB,6BACDpB,UAAUoB,OACvBrE,IAAIY,kBAAmB,MAG/BmD,gBAAgBF,aAAQG,sEACpBhE,IAAII,SAASE,UAAYuD,QAAQL,OAAOK,QAAQhB,IAAI,EAChDgB,SACA7D,IAAIU,gBAAkBmD,QACtB7D,IAAIW,iBAAmB,KACvBX,IAAIY,kBAAmB,iBAClB,CAAC,CACFS,WAAY,yCACZC,KAAM,CAAEgD,OAAQT,QAAQhB,GAAI0B,YAAavE,IAAIQ,gBAAgBqC,OAC7D,GAAGtB,MAAK,SAASC,UACjBxB,IAAIW,kBAAmB,wCAAiBa,UAAS,GACjDxB,IAAIO,mBAAqBP,IAAIW,iBAC7BX,IAAIY,kBAAmB,EACnBoD,aACA1B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,GAAK,IAAMgB,QAAQhB,OAEnEE,OAAM,SAASsB,6BACDpB,UAAUoB,OACvBrE,IAAIY,kBAAmB,WAGtB4D,aAAaR,aAG1BQ,mBAAaR,sEACTV,MAAMI,KAAK,qBAAqBM,YAChChE,IAAII,SAASE,UAAY,EACzBN,IAAIU,gBAAkB,KACtBV,IAAIW,iBAAmB,KACvBX,IAAIO,mBAAqBP,IAAIQ,gBACzBwD,aACA1B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,8gBAhO3D4B,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,8CAGJH,IAAII,oCAGJJ,IAAIK,iCAEJL,IAAIM,2BAGJzB,MAAQ,IAAI0B,kBAAS,sBAErBjE,SAAU,8BAAa,CACvBC,MAAO,CACHiE,6BAA8B,+BAC9BC,sBAAuB"} \ 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 c54d7e5..2fb9457 100644 --- a/amd/build/page-edit-plan.min.js +++ b/amd/build/page-edit-plan.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-edit-plan",["exports","core/str","core/ajax","core/notification","./vue/vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./util/debugger","./util/string-helper","./studyplan-processor","./downloader","./util/date-helper","./util/premium","./util/mform-helper","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_premium,_mformHelper,_portalVue,_bootstrapVue){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid,options){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;debug.info("options",options),null===options||"object"!=typeof options||Array.isArray(options)?options={defaultAggregation:"core"}:options.defaultAggregation||(options.defaultAggregation="core");let app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",idnumber:"",slots:4,startdate:"2020-08-01",enddate:"",context:contextid,aggregation:options.defaultAggregation,aggregation_config:""}},activestudyplan:null,activepage:null,loadingstudyplan:!1,studyplans:[],templatecount:0,text:strings.studyplan,usedcontexts:[]},created(){this.$root.$on("studyplanRemoved",(studyplan=>{app.activestudyplan==studyplan&&(app.activestudyplan=null);let index=null;for(let idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted(){this.initialize()},computed:{premiumenabled:_premium.premiumenabled,dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},methods:{initialize(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].then((function(response){const timingval={future:0,present:1,past:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b);let t=timingval[timinga]-timingval[timingb];return 0==t&&(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime(),0==t&&(t=a.name.localeCompare(b.name))),t})),app.studyplans=response;const hash=location.hash.replace("#","");if(hash){const id=hash;for(const p of app.studyplans)if(p.id==id){app.selectStudyplan(id);break}}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_available_categories",args:{operation:"edit",refcontext_id:contextid}}])[0].then((function(response){app.usedcontexts=response})).catch(_notification.default.exception),this.refreshTemplateCount()},refreshTemplateCount(){(0,_ajax.call)([{methodname:"local_treestudyplan_count_templates",args:{}}])[0].then((function(response){app.templatecount=response})).catch(_notification.default.exception)},closeStudyplan(){app.activestudyplan=null,window.location.hash=""},movedStudyplan(plan,from,to){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),setTimeout((()=>{window.location.search=params.toString()}),50)},onStudyPlanCreated(newstudyplan){if(newstudyplan.context_id!=contextid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",newstudyplan.context_id),resetAllFormDirtyStates(),window.location=window.location.pathname+"?"+params.toString()+"#"+newstudyplan.id}else app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan.id)},switchContext(ctxid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",ctxid),setTimeout((()=>{window.location.href=window.location.pathname+"?"+params.toString()}),50)},selectStudyplan(studyplanid){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplanid}}])[0].then((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response),debug.info("studyplan processed"),app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},import_studyplan(){const self=this;(0,_downloader.upload)(((filename,content)=>{(0,_ajax.call)([{methodname:"local_treestudyplan_import_plan",args:{content:content,format:"application/json",context_id:contextid}}])[0].then((function(response){response.success?self.initialize():debug.error("Import failed: ",response.msg)})).catch(_notification.default.exception)}),"application/json")},export_plan(plan,format){null!=format&&["json","csv"].includes(format)||(format="json"),(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:plan.id,format:format}}])[0].then((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).catch(_notification.default.exception)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_mformHelper=_interopRequireDefault(_mformHelper),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue);var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_mformHelper.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);const debug=new _debugger.default("treestudyplan");let resetAllFormDirtyStates=()=>{};("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require(["core_form/changechecker"],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require("core_form/changechecker")):Promise.resolve(_systemImportTransformerGlobalIdentifier["core_form/changechecker"])).then((ns=>{debug.info(ns),ns.resetAllFormDirtyStates&&(resetAllFormDirtyStates=ns.resetAllFormDirtyStates)})).catch((()=>{}));let strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder",advanced_import_from_file:"advanced_import_from_file",advanced_create_from_template:"advanced_create_from_template",studyplan_add:"studyplan_add"}})})); +define("local_treestudyplan/page-edit-plan",["exports","core/str","core/ajax","core/notification","./vue/vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./util/debugger","./util/browserbuttonevents","./util/string-helper","./studyplan-processor","./downloader","./util/date-helper","./util/premium","./util/mform-helper","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_browserbuttonevents,_stringHelper,_studyplanProcessor,_downloader,_dateHelper,_premium,_mformHelper,_portalVue,_bootstrapVue){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid,options){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;debug.info("options",options),null===options||"object"!=typeof options||Array.isArray(options)?options={defaultAggregation:"core"}:options.defaultAggregation||(options.defaultAggregation="core");let app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",idnumber:"",slots:4,startdate:"2020-08-01",enddate:"",context:contextid,aggregation:options.defaultAggregation,aggregation_config:""}},activestudyplan:null,activepage:null,loadingstudyplan:!1,studyplans:[],templatecount:0,text:strings.studyplan,usedcontexts:[]},created(){this.$root.$on("studyplanRemoved",(studyplan=>{app.activestudyplan==studyplan&&(app.activestudyplan=null);let index=null;for(let idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted(){this.initialize(),(0,_browserbuttonevents.addBrowserButtonEvent)(this.backPressed)},beforeunmount(){},computed:{premiumenabled:_premium.premiumenabled,dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},methods:{backPressed(){debug.log("Back button pressed"),app.activestudyplan&&(debug.log("Closing studyplan"),this.closeStudyplan())},initialize(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].then((function(response){const timingval={future:0,present:1,past:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b);let t=timingval[timinga]-timingval[timingb];return 0==t&&(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime(),0==t&&(t=a.name.localeCompare(b.name))),t})),app.studyplans=response;const hash=location.hash.replace("#","");if(hash){const id=hash;for(const p of app.studyplans)if(p.id==id){app.selectStudyplan(id);break}}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_available_categories",args:{operation:"edit",refcontext_id:contextid}}])[0].then((function(response){app.usedcontexts=response})).catch(_notification.default.exception),this.refreshTemplateCount()},refreshTemplateCount(){(0,_ajax.call)([{methodname:"local_treestudyplan_count_templates",args:{}}])[0].then((function(response){app.templatecount=response})).catch(_notification.default.exception)},closeStudyplan(){app.activestudyplan=null,window.location.hash=""},movedStudyplan(plan,from,to){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),setTimeout((()=>{window.location.search=params.toString()}),50)},onStudyPlanCreated(newstudyplan){if(newstudyplan.context_id!=contextid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",newstudyplan.context_id),resetAllFormDirtyStates(),window.location=window.location.pathname+"?"+params.toString()+"#"+newstudyplan.id}else app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan.id)},switchContext(ctxid){const params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",ctxid),setTimeout((()=>{window.location.href=window.location.pathname+"?"+params.toString()}),50)},selectStudyplan(studyplanid){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplanid}}])[0].then((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response),debug.info("studyplan processed"),app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},import_studyplan(){const self=this;(0,_downloader.upload)(((filename,content)=>{(0,_ajax.call)([{methodname:"local_treestudyplan_import_plan",args:{content:content,format:"application/json",context_id:contextid}}])[0].then((function(response){response.success?self.initialize():debug.error("Import failed: ",response.msg)})).catch(_notification.default.exception)}),"application/json")},export_plan(plan,format){null!=format&&["json","csv"].includes(format)||(format="json"),(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:plan.id,format:format}}])[0].then((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).catch(_notification.default.exception)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_mformHelper=_interopRequireDefault(_mformHelper),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue);var _systemImportTransformerGlobalIdentifier="undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:{};function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_mformHelper.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);const debug=new _debugger.default("treestudyplan");let resetAllFormDirtyStates=()=>{};("function"==typeof _systemImportTransformerGlobalIdentifier.define&&_systemImportTransformerGlobalIdentifier.define.amd?new Promise((function(resolve,reject){_systemImportTransformerGlobalIdentifier.require(["core_form/changechecker"],resolve,reject)})):"undefined"!=typeof module&&module.exports&&"undefined"!=typeof require||"undefined"!=typeof module&&module.component&&_systemImportTransformerGlobalIdentifier.require&&"component"===_systemImportTransformerGlobalIdentifier.require.loader?Promise.resolve(require("core_form/changechecker")):Promise.resolve(_systemImportTransformerGlobalIdentifier["core_form/changechecker"])).then((ns=>{debug.info(ns),ns.resetAllFormDirtyStates&&(resetAllFormDirtyStates=ns.resetAllFormDirtyStates)})).catch((()=>{}));let strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder",advanced_import_from_file:"advanced_import_from_file",advanced_create_from_template:"advanced_create_from_template",studyplan_add:"studyplan_add"}})})); //# 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 b5f14b4..df83d67 100644 --- a/amd/build/page-edit-plan.min.js.map +++ b/amd/build/page-edit-plan.min.js.map @@ -1 +1 @@ -{"version":3,"file":"page-edit-plan.min.js","sources":["../src/page-edit-plan.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint no-unused-vars: \"off\" */\n/*eslint linebreak-style: \"off\" */\n/*eslint no-trailing-spaces: \"off\" */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {get_string,get_strings} from 'core/str';\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\n//import {resetAllFormDirtyStates} from 'core_form/changechecker'; // Moodle 4.00+ only\n\nimport Vue from './vue/vue';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\nimport Debugger from './util/debugger';\n\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\nimport {studyplanTiming} from './util/date-helper';\nimport { premiumenabled, premiumstatus } from \"./util/premium\";\nimport mFormComponents from \"./util/mform-helper\";\nVue.use(mFormComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nconst debug = new Debugger(\"treestudyplan\");\n\nlet resetAllFormDirtyStates = () => {};\nimport('core_form/changechecker').then((ns) => {\n debug.info(ns);\n if(ns.resetAllFormDirtyStates) {\n resetAllFormDirtyStates = ns.resetAllFormDirtyStates;\n }\n}).catch(()=>{});\n\n\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n advanced_import_from_file: 'advanced_import_from_file',\n advanced_create_from_template: 'advanced_create_from_template',\n studyplan_add: \"studyplan_add\",\n },\n});\n\n/**\n * Initialize the Page\n * @param {int} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)\n * @param {object} options Options to be passed to this script\n */\nexport function init(contextid,categoryid,options) {\n // Make sure the id's are numeric and integer\n if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;}\n else { contextid = Number(contextid);} // ensure a numeric value instead of string\n if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;}\n else { categoryid = Number(categoryid);} // ensure a numeric value instead of string\n\n debug.info(\"options\",options);\n if ( options !== null && typeof options === 'object' && !Array.isArray(options) ) {\n if ( !options.defaultAggregation ) {\n options.defaultAggregation = \"core\";\n }\n \n } else {\n options = { defaultAggregation: \"core\"};\n }\n\n // Setup the initial Vue app for this page\n let app = new Vue({\n el: '#root',\n data: {\n create: {\n studyplan: {\n name: '',\n shortname: '',\n description: '',\n idnumber: '',\n slots : 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: options.defaultAggregation,\n aggregation_config: '',\n }\n },\n\n activestudyplan: null,\n activepage: null,\n loadingstudyplan: false,\n studyplans: [],\n templatecount: 0,\n\n text: strings.studyplan,\n usedcontexts: [],\n },\n created() {\n this.$root.$on('studyplanRemoved',(studyplan)=>{\n\n if(app.activestudyplan == studyplan){\n app.activestudyplan = null;\n }\n\n // remove studyplan from index list\n let index = null;\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == studyplan.id){\n index = idx;\n break;\n }\n }\n if(index){\n app.studyplans.splice(index, 1);\n }\n\n });\n },\n mounted() {\n this.initialize();\n },\n computed: {\n premiumenabled,\n dropdown_title(){\n if(this.activestudyplan && this.activestudyplan.name){\n return this.activestudyplan.name;\n }\n else{\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid(){\n return contextid;\n },\n\n },\n methods: {\n initialize() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: { context_id: contextid}\n }])[0].then(function(response){\n const timingval = { future: 0, present: 1, past: 2, };\n response.sort((a,b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n \n let t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by start date if timing is equal\n t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();\n \n if (t == 0) {\n // sort by name if timing is equal\n t = a.name.localeCompare(b.name);\n }\n }\n return t;\n });\n app.studyplans = response;\n \n // load studyplan from hash if applicable\n const hash = location.hash.replace('#','');\n if(hash){\n const id = hash;\n for(const p of app.studyplans) {\n if (p.id == id) {\n app.selectStudyplan(id);\n break;\n }\n }\n }\n }).catch(notification.exception);\n\n call([{\n methodname: 'local_treestudyplan_list_available_categories',\n args: { operation: 'edit', refcontext_id: contextid}\n }])[0].then(function(response){\n app.usedcontexts = response;\n }).catch(notification.exception);\n\n this.refreshTemplateCount();\n },\n refreshTemplateCount(){\n call([{\n methodname: 'local_treestudyplan_count_templates',\n args: { }\n }])[0].then(function(response){\n app.templatecount = response;\n }).catch(notification.exception);\n },\n closeStudyplan() {\n app.activestudyplan = null;\n window.location.hash = '';\n },\n movedStudyplan(plan,from,to) {\n // reload the page in the new context (needed, since a number of links are not reactive in the page)\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", to);\n setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location.search = params.toString();\n },50);\n },\n onStudyPlanCreated(newstudyplan){\n if (newstudyplan.context_id != contextid) {\n // Study plan has changed context id - reload page into new context id and show the plan\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", newstudyplan.context_id);\n // Make sure the form is no longer dirty before reloading the page - avoid beforeunload handler triggering.\n resetAllFormDirtyStates();\n window.location = window.location.pathname + \"?\" + params.toString() + \"#\" + newstudyplan.id;\n } else {\n app.studyplans.push(newstudyplan);\n app.selectStudyplan(newstudyplan.id);\n }\n },\n switchContext(ctxid){\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set('contextid', ctxid);\n setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location.href = window.location.pathname + \"?\" + params.toString();\n },50);\n },\n selectStudyplan(studyplanid){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplanid}\n }])[0].then(function(response){\n app.activestudyplan = ProcessStudyplan(response);\n debug.info('studyplan processed');\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n import_studyplan(){\n const self = this;\n upload((filename,content)=>{\n call([{\n methodname: 'local_treestudyplan_import_plan',\n args: {\n content: content,\n format: \"application/json\",\n context_id: contextid,\n },\n }])[0].then(function(response){\n if(response.success){\n self.initialize();\n } else {\n debug.error(\"Import failed: \",response.msg);\n }\n\n }).catch(notification.exception);\n }, \"application/json\");\n },\n export_plan(plan,format){\n let self = this;\n if(format == undefined || ![\"json\",\"csv\"].includes(format)){\n format = \"json\";\n }\n call([{\n methodname: 'local_treestudyplan_export_plan',\n args: {\n studyplan_id: plan.id,\n format: format\n },\n }])[0].then(function(response){\n\n download(plan.shortname+\".json\",response.content,response.format);\n }).catch(notification.exception);\n },\n \n },\n });\n}\n\n"],"names":["contextid","categoryid","options","undefined","Number","isInteger","debug","info","Array","isArray","defaultAggregation","app","Vue","el","data","create","studyplan","name","shortname","description","idnumber","slots","startdate","enddate","context","aggregation","aggregation_config","activestudyplan","activepage","loadingstudyplan","studyplans","templatecount","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","initialize","computed","premiumenabled","dropdown_title","this","studyplan_select_placeholder","methods","methodname","args","context_id","then","response","timingval","future","present","past","sort","a","b","timinga","timingb","t","Date","getTime","localeCompare","hash","location","replace","p","selectStudyplan","catch","notification","exception","operation","refcontext_id","refreshTemplateCount","closeStudyplan","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","setTimeout","toString","onStudyPlanCreated","newstudyplan","resetAllFormDirtyStates","pathname","push","switchContext","ctxid","href","studyplanid","error","import_studyplan","self","filename","content","format","success","msg","export_plan","includes","studyplan_id","use","EditorComponents","TSComponents","ModalComponents","mFormComponents","PortalVue","BootstrapVue","Debugger","ns","advanced_import_from_file","advanced_create_from_template","studyplan_add"],"mappings":"8rBAmEqBA,UAAUC,WAAWC,SAEiDF,eAApFG,IAAcH,YAAcI,OAAOC,UAAUD,OAAOJ,aAAeA,UAAY,EAAiB,EAChFI,OAAOJ,WAEnBC,gBADJE,IAAcF,YAAeG,OAAOC,UAAUD,OAAOH,aACpCG,OAAOH,YADyD,EAGpFK,MAAMC,KAAK,UAAUL,SACJ,OAAZA,SAAuC,iBAAZA,SAAyBM,MAAMC,QAAQP,SAMnEA,QAAU,CAAEQ,mBAAoB,QAL1BR,QAAQQ,qBACVR,QAAQQ,mBAAqB,YAQjCC,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,OAAQ,CACJC,UAAW,CACPC,KAAM,GACNC,UAAW,GACXC,YAAa,GACbC,SAAU,GACVC,MAAQ,EACRC,UAAW,aACXC,QAAS,GACTC,QAASxB,UACTyB,YAAavB,QAAQQ,mBACrBgB,mBAAoB,KAI5BC,gBAAiB,KACjBC,WAAY,KACZ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B,kBAAmB,MAG/ByE,yBACUC,KAAOxD,6BACN,CAACyD,SAASC,0BACR,CAAC,CACFvD,WAAY,kCACZC,KAAM,CACFsD,QAASA,QACTC,OAAQ,mBACRtD,WAAYpD,cAEhB,GAAGqD,MAAK,SAASC,UACdA,SAASqD,QACRJ,KAAK5D,aAELrC,MAAM+F,MAAM,kBAAkB/C,SAASsD,QAG5CnC,MAAMC,sBAAaC,aACvB,qBAEPkC,YAAY3B,KAAKwB,QAEAvG,MAAVuG,QAAwB,CAAC,OAAO,OAAOI,SAASJ,UAC/CA,OAAS,uBAER,CAAC,CACExD,WAAY,kCACZC,KAAM,CACF4D,aAAc7B,KAAK1C,GACnBkE,OAAQA,WAEZ,GAAGrD,MAAK,SAASC,mCAER4B,KAAKhE,UAAU,QAAQoC,SAASmD,QAAQnD,SAASoD,WAC3DjC,MAAMC,sBAAaC,muBArRtCqC,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,oCASJH,IAAII,mCAGJJ,IAAIK,iCAEJL,IAAIM,6BAGFhH,MAAQ,IAAIiH,kBAAS,qBAEvBzB,wBAA0B,+nBACIzC,MAAMmE,KACpClH,MAAMC,KAAKiH,IACRA,GAAG1B,0BACFA,wBAA0B0B,GAAG1B,4BAElCrB,OAAM,aAILxC,SAAU,8BAAa,CACvBjB,UAAW,CACPgC,6BAA8B,+BAC9ByE,0BAA2B,4BAC3BC,8BAA+B,gCAC/BC,cAAe"} \ No newline at end of file +{"version":3,"file":"page-edit-plan.min.js","sources":["../src/page-edit-plan.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint no-unused-vars: \"off\" */\n/*eslint linebreak-style: \"off\" */\n/*eslint no-trailing-spaces: \"off\" */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {get_string,get_strings} from 'core/str';\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\n//import {resetAllFormDirtyStates} from 'core_form/changechecker'; // Moodle 4.00+ only\n\nimport Vue from './vue/vue';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\nimport Debugger from './util/debugger';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\nimport {studyplanTiming} from './util/date-helper';\nimport { premiumenabled, premiumstatus } from \"./util/premium\";\nimport mFormComponents from \"./util/mform-helper\";\nVue.use(mFormComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nconst debug = new Debugger(\"treestudyplan\");\n\nlet resetAllFormDirtyStates = () => {};\nimport('core_form/changechecker').then((ns) => {\n debug.info(ns);\n if(ns.resetAllFormDirtyStates) {\n resetAllFormDirtyStates = ns.resetAllFormDirtyStates;\n }\n}).catch(()=>{});\n\n\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n advanced_import_from_file: 'advanced_import_from_file',\n advanced_create_from_template: 'advanced_create_from_template',\n studyplan_add: \"studyplan_add\",\n },\n});\n\n/**\n * Initialize the Page\n * @param {int} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)\n * @param {object} options Options to be passed to this script\n */\nexport function init(contextid,categoryid,options) {\n // Make sure the id's are numeric and integer\n if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;}\n else { contextid = Number(contextid);} // ensure a numeric value instead of string\n if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;}\n else { categoryid = Number(categoryid);} // ensure a numeric value instead of string\n\n debug.info(\"options\",options);\n if ( options !== null && typeof options === 'object' && !Array.isArray(options) ) {\n if ( !options.defaultAggregation ) {\n options.defaultAggregation = \"core\";\n }\n \n } else {\n options = { defaultAggregation: \"core\"};\n }\n\n // Setup the initial Vue app for this page\n let app = new Vue({\n el: '#root',\n data: {\n create: {\n studyplan: {\n name: '',\n shortname: '',\n description: '',\n idnumber: '',\n slots : 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: options.defaultAggregation,\n aggregation_config: '',\n }\n },\n\n activestudyplan: null,\n activepage: null,\n loadingstudyplan: false,\n studyplans: [],\n templatecount: 0,\n\n text: strings.studyplan,\n usedcontexts: [],\n },\n created() {\n this.$root.$on('studyplanRemoved',(studyplan)=>{\n\n if(app.activestudyplan == studyplan){\n app.activestudyplan = null;\n }\n\n // remove studyplan from index list\n let index = null;\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == studyplan.id){\n index = idx;\n break;\n }\n }\n if(index){\n app.studyplans.splice(index, 1);\n }\n\n });\n },\n mounted() {\n this.initialize();\n addBrowserButtonEvent(this.backPressed);\n },\n beforeunmount() {\n\n },\n computed: {\n premiumenabled,\n dropdown_title(){\n if(this.activestudyplan && this.activestudyplan.name){\n return this.activestudyplan.name;\n }\n else{\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid(){\n return contextid;\n },\n\n },\n methods: {\n backPressed() {\n debug.log(\"Back button pressed\");\n if (app.activestudyplan) {\n debug.log(\"Closing studyplan\");\n this.closeStudyplan();\n }\n },\n initialize() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: { context_id: contextid}\n }])[0].then(function(response){\n const timingval = { future: 0, present: 1, past: 2, };\n response.sort((a,b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n \n let t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by start date if timing is equal\n t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();\n \n if (t == 0) {\n // sort by name if timing is equal\n t = a.name.localeCompare(b.name);\n }\n }\n return t;\n });\n app.studyplans = response;\n \n // load studyplan from hash if applicable\n const hash = location.hash.replace('#','');\n if(hash){\n const id = hash;\n for(const p of app.studyplans) {\n if (p.id == id) {\n app.selectStudyplan(id);\n break;\n }\n }\n }\n }).catch(notification.exception);\n\n call([{\n methodname: 'local_treestudyplan_list_available_categories',\n args: { operation: 'edit', refcontext_id: contextid}\n }])[0].then(function(response){\n app.usedcontexts = response;\n }).catch(notification.exception);\n\n this.refreshTemplateCount();\n },\n refreshTemplateCount(){\n call([{\n methodname: 'local_treestudyplan_count_templates',\n args: { }\n }])[0].then(function(response){\n app.templatecount = response;\n }).catch(notification.exception);\n },\n closeStudyplan() {\n app.activestudyplan = null;\n window.location.hash = '';\n },\n movedStudyplan(plan,from,to) {\n // reload the page in the new context (needed, since a number of links are not reactive in the page)\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", to);\n setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location.search = params.toString();\n },50);\n },\n onStudyPlanCreated(newstudyplan){\n if (newstudyplan.context_id != contextid) {\n // Study plan has changed context id - reload page into new context id and show the plan\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", newstudyplan.context_id);\n // Make sure the form is no longer dirty before reloading the page - avoid beforeunload handler triggering.\n resetAllFormDirtyStates();\n window.location = window.location.pathname + \"?\" + params.toString() + \"#\" + newstudyplan.id;\n } else {\n app.studyplans.push(newstudyplan);\n app.selectStudyplan(newstudyplan.id);\n }\n },\n switchContext(ctxid){\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set('contextid', ctxid);\n setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location.href = window.location.pathname + \"?\" + params.toString();\n },50);\n },\n selectStudyplan(studyplanid){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplanid}\n }])[0].then(function(response){\n app.activestudyplan = ProcessStudyplan(response);\n debug.info('studyplan processed');\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n import_studyplan(){\n const self = this;\n upload((filename,content)=>{\n call([{\n methodname: 'local_treestudyplan_import_plan',\n args: {\n content: content,\n format: \"application/json\",\n context_id: contextid,\n },\n }])[0].then(function(response){\n if(response.success){\n self.initialize();\n } else {\n debug.error(\"Import failed: \",response.msg);\n }\n\n }).catch(notification.exception);\n }, \"application/json\");\n },\n export_plan(plan,format){\n let self = this;\n if(format == undefined || ![\"json\",\"csv\"].includes(format)){\n format = \"json\";\n }\n call([{\n methodname: 'local_treestudyplan_export_plan',\n args: {\n studyplan_id: plan.id,\n format: format\n },\n }])[0].then(function(response){\n\n download(plan.shortname+\".json\",response.content,response.format);\n }).catch(notification.exception);\n },\n \n },\n });\n}\n\n"],"names":["contextid","categoryid","options","undefined","Number","isInteger","debug","info","Array","isArray","defaultAggregation","app","Vue","el","data","create","studyplan","name","shortname","description","idnumber","slots","startdate","enddate","context","aggregation","aggregation_config","activestudyplan","activepage","loadingstudyplan","studyplans","templatecount","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","initialize","this","backPressed","beforeunmount","computed","premiumenabled","dropdown_title","studyplan_select_placeholder","methods","log","closeStudyplan","methodname","args","context_id","then","response","timingval","future","present","past","sort","a","b","timinga","timingb","t","Date","getTime","localeCompare","hash","location","replace","p","selectStudyplan","catch","notification","exception","operation","refcontext_id","refreshTemplateCount","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","setTimeout","toString","onStudyPlanCreated","newstudyplan","resetAllFormDirtyStates","pathname","push","switchContext","ctxid","href","studyplanid","error","import_studyplan","self","filename","content","format","success","msg","export_plan","includes","studyplan_id","use","EditorComponents","TSComponents","ModalComponents","mFormComponents","PortalVue","BootstrapVue","Debugger","ns","advanced_import_from_file","advanced_create_from_template","studyplan_add"],"mappings":"gvBAoEqBA,UAAUC,WAA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AIC,iDAGJD,IAAIE,+CAGJF,IAAIG,oCAUJH,IAAII,mCAGJJ,IAAIK,iCAEJL,IAAIM,6BAGFnH,MAAQ,IAAIoH,kBAAS,qBAEvBzB,wBAA0B,+nBACIxC,MAAMkE,KACpCrH,MAAMC,KAAKoH,IACRA,GAAG1B,0BACFA,wBAA0B0B,GAAG1B,4BAElCpB,OAAM,aAIL5C,SAAU,8BAAa,CACvBjB,UAAW,CACPkC,6BAA8B,+BAC9B0E,0BAA2B,4BAC3BC,8BAA+B,gCAC/BC,cAAe"} \ No newline at end of file diff --git a/amd/build/page-view-plan.min.js b/amd/build/page-view-plan.min.js index 6e6f455..57c3f27 100644 --- a/amd/build/page-view-plan.min.js +++ b/amd/build/page-view-plan.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-view-plan",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-processor","./util/date-helper","./report-viewer-components","./treestudyplan-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_reportViewerComponents,_treestudyplanComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;let app=new _vue.default({el:"#root",data:{displayedstudyplan:null,activestudyplan:null,associatedstudents:[],selectedstudent:null,studentstudyplan:null,loadingstudyplan:!1,studyplans:[],text:strings.studyplan,toolbox:{right:!0},usedcontexts:[]},async mounted(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:contextid}}])[0].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)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((function(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)},computed:{dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:()=>contextid},methods:{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(){app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,window.location.hash=""},selectStudyplan(studyplan,studentid){app.loadingstudyplan=!0,app.activestudyplan=null,app.associatedstudents=[],app.selectedstudent=null,app.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].then((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),app.displayedstudyplan=app.activestudyplan,app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id,(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated_grouped",args:{studyplan_id:studyplan.id}}])[0].then((function(response){if(app.associatedstudents=response,studentid)for(const group of app.associatedstudents)for(const student of group.users)if(student.id==studentid){app.showStudentView(student);break}})).catch(_notification.default.exception)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){app.selectedstudent=student,app.studentstudyplan=null,student&&(app.loadingstudyplan=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_get_user_studyplan",args:{userid:student.id,studyplanid:app.activestudyplan.id}}])[0].then((function(response){app.studentstudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,window.location.hash=app.activestudyplan.id+"-"+student.id})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1})))},showOverview(){app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,window.location.hash=app.activestudyplan.id}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);new _debugger.default("treestudyplanviewer");let strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); +define("local_treestudyplan/page-view-plan",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-processor","./util/date-helper","./util/browserbuttonevents","./report-viewer-components","./treestudyplan-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_browserbuttonevents,_reportViewerComponents,_treestudyplanComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(contextid,categoryid){contextid=void 0===contextid||!Number.isInteger(Number(contextid))||contextid<1?1:Number(contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;let app=new _vue.default({el:"#root",data:{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((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]);break}})).catch(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_available_categories",args:{operation:"view",refcontext_id:contextid}}])[0].then((function(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:{dropdown_title(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},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((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated_grouped",args:{studyplan_id:studyplan.id}}])[0].then((function(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((function(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];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),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);let debug=new _debugger.default("treestudyplanviewer"),strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); //# sourceMappingURL=page-view-plan.min.js.map \ No newline at end of file diff --git a/amd/build/page-view-plan.min.js.map b/amd/build/page-view-plan.min.js.map index a2faa05..414a06f 100644 --- a/amd/build/page-view-plan.min.js.map +++ b/amd/build/page-view-plan.min.js.map @@ -1 +1 @@ -{"version":3,"file":"page-view-plan.min.js","sources":["../src/page-view-plan.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint no-unused-vars: \"off\" */\n/*eslint linebreak-style: \"off\" */\n/*eslint no-trailing-spaces: \"off\" */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\nimport TSComponents from './treestudyplan-components';\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplanviewer\");\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n },\n});\n\n/**\n * Initialize the Page\n * @param {int} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)\n */\nexport function init(contextid,categoryid) {\n // Make sure the id's are numeric and integer\n if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;}\n else { contextid = Number(contextid);} // ensure a numeric value instead of string\n if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;}\n else { categoryid = Number(categoryid);} // ensure a numeric value instead of string\n\n const in_systemcontext = (contextid <= 1);\n\n let app = new Vue({\n el: '#root',\n data: {\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.studyplan,\n toolbox: {\n right: true,\n },\n usedcontexts: [],\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: {context_id: contextid}\n }])[0].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 }\n else {\n return t;\n }\n });\n app.studyplans = response;\n // load studyplan from hash if applicable\n const hash = window.location.hash.replace('#','');\n const parts = hash.split(\"-\");\n\n if(!!parts && parts.length > 0){\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == parts[0]){\n app.selectStudyplan(app.studyplans[idx],parts[1]);\n break;\n }\n }\n }\n }).catch(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_available_categories',\n args: { operation: 'view', refcontext_id: contextid}\n }])[0].then(function(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 }).catch(notification.exception);\n },\n computed: {\n dropdown_title(){\n if(this.activestudyplan && this.activestudyplan.name){\n return this.activestudyplan.name;\n }\n else{\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid(){\n return contextid;\n }\n },\n methods: {\n switchContext(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() {\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n window.location.hash = '';\n },\n\n selectStudyplan(studyplan,studentid){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.selectedstudent = null;\n app.studentstudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: { id: studyplan.id}\n }])[0].then(function(response){\n app.activestudyplan = ProcessStudyplan(response,true);\n app.displayedstudyplan = app.activestudyplan;\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n call([{\n methodname: 'local_treestudyplan_all_associated_grouped',\n args: { studyplan_id: studyplan.id}\n }])[0].then(function(response){\n app.associatedstudents = response;\n if(studentid){\n for(const group of app.associatedstudents) {\n for(const student of group.users){\n if(student.id == studentid){\n app.showStudentView(student);\n break;\n }\n }\n }\n }\n }).catch(notification.exception);\n\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student){\n app.selectedstudent = student;\n app.studentstudyplan = null;\n if (student) {\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(function(response){\n app.studentstudyplan = ProcessStudyplan(response,false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }).catch(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n }\n },\n showOverview(){\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n window.location.hash = app.activestudyplan.id;\n }\n\n },\n });\n}\n"],"names":["contextid","categoryid","undefined","Number","isInteger","app","Vue","el","data","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","studyplan","toolbox","right","usedcontexts","methodname","args","context_id","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","refcontext_id","contexts","ix","cat","studyplancount","push","computed","dropdown_title","this","studyplan_select_placeholder","methods","switchContext","ctxid","params","URLSearchParams","search","delete","set","setTimeout","href","pathname","toString","closeStudyplan","studentid","studyplan_id","group","student","users","showStudentView","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"kqBA2CqBA,UAAUC,YAE4DD,eAApFE,IAAcF,YAAcG,OAAOC,UAAUD,OAAOH,aAAeA,UAAY,EAAiB,EAChFG,OAAOH,WAEnBC,gBADJC,IAAcD,YAAeE,OAAOC,UAAUD,OAAOF,aACpCE,OAAOF,YADyD,MAKhFI,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,mBAAoB,KACpBC,gBAAiB,KACjBC,mBAAoB,GACpBC,gBAAiB,KACjBC,iBAAkB,KAClBC,kBAAkB,EAClBC,WAAY,GACZC,KAAMC,QAAQC,UACdC,QAAS,CACLC,OAAO,GAEXC,aAA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C,6BACD/B,UAAU+B,OACvB7E,IAAIS,kBAAmB,OAInCuE,eACIhF,IAAIO,gBAAkB,KACtBP,IAAIQ,iBAAmB,KACvBR,IAAII,mBAAqBJ,IAAIK,gBAC7B8B,OAAOC,SAASC,KAAOrC,IAAIK,gBAAgBqC,+bA3LvDuC,IAAIC,8CAGJD,IAAIE,oCAGJF,IAAIG,iCAEJH,IAAII,uBAGI,IAAIC,kBAAS,2BAErB1E,SAAU,8BAAa,CACvBC,UAAW,CACP4C,6BAA8B"} \ No newline at end of file +{"version":3,"file":"page-view-plan.min.js","sources":["../src/page-view-plan.js"],"sourcesContent":["/*eslint no-var: \"error\" */\n/*eslint no-unused-vars: \"off\" */\n/*eslint linebreak-style: \"off\" */\n/*eslint no-trailing-spaces: \"off\" */\n/*eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\nimport TSComponents from './treestudyplan-components';\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplanviewer\");\n\nlet strings = load_strings({\n studyplan: {\n studyplan_select_placeholder: 'studyplan_select_placeholder',\n },\n});\n\n/**\n * Initialize the Page\n * @param {int} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)\n */\nexport function init(contextid,categoryid) {\n // Make sure the id's are numeric and integer\n if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;}\n else { contextid = Number(contextid);} // ensure a numeric value instead of string\n if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;}\n else { categoryid = Number(categoryid);} // ensure a numeric value instead of string\n\n const in_systemcontext = (contextid <= 1);\n\n let app = new Vue({\n el: '#root',\n data: {\n 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(function(response){\n const timingval = { present: 0, past: 1, future: 2};\n response.sort((a,b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n\n const t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by name if timing is equal\n return a.name.localeCompare(b.name);\n }\n else {\n return t;\n }\n });\n app.studyplans = response;\n // load studyplan from hash if applicable\n const hash = window.location.hash.replace('#','');\n const parts = hash.split(\"-\");\n\n if(!!parts && parts.length > 0 && 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 }).catch(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_available_categories',\n args: { operation: 'view', refcontext_id: contextid}\n }])[0].then(function(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 }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\n dropdown_title(){\n if(this.activestudyplan && this.activestudyplan.name){\n return this.activestudyplan.name;\n }\n else{\n return this.text.studyplan_select_placeholder;\n }\n },\n contextid(){\n return contextid;\n }\n },\n methods: {\n 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(function(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(function(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 }).catch(notification.exception);\n\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(function(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 }).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 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","context_id","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","refcontext_id","contexts","ix","cat","studyplancount","push","this","navChanged","computed","dropdown_title","studyplan_select_placeholder","methods","debug","log","closeStudyplan","info","plan","group","student","users","showStudentView","switchContext","ctxid","params","URLSearchParams","search","delete","set","setTimeout","href","pathname","toString","updatehash","studyplan_id","foundstudent","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"otBA4CqBA,UAAUC,YAE4DD,eAApFE,IAAcF,YAAcG,OAAOC,UAAUD,OAAOH,aAAeA,UAAY,EAAiB,EAChFG,OAAOH,WAEnBC,gBADJC,IAAcD,YAAeE,OAAOC,UAAUD,OAAOF,aACpCE,OAAOF,YADyD,MAKhFI,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,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,CAACC,WAAY3B,cACnB,GAAG4B,MAAK,SAASC,gBACXC,UAAY,CAAEC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GACjDJ,SAASK,MAAK,CAACC,EAAEC,WACPC,SAAU,+BAAgBF,GAC1BG,SAAU,+BAAgBF,GAE1BG,EAAIT,UAAUO,SAAWP,UAAUQ,gBACjC,GAALC,EAEQJ,EAAEK,KAAKC,cAAcL,EAAEI,MAGvBD,KAGflC,IAAIa,WAAaW,eAGXa,MADOC,OAAOC,SAASC,KAAKC,QAAQ,IAAI,IAC3BC,MAAM,QAEpBL,OAASA,MAAMM,OAAS,GAAiB,IAAZN,MAAM,OAChC,IAAIO,OAAO5C,IAAIa,cACZb,IAAIa,WAAW+B,KAAKC,IAAMR,MAAM,GAAG,CAClCrC,IAAI8C,gBAAgB9C,IAAIa,WAAW+B,KAAKP,MAAM,cAK3DU,MAAMC,sBAAaC,0BACjB,CAAC,CACF7B,WAAY,gDACZC,KAAM,CAAE6B,UAAW,OAAQC,cAAexD,cAC1C,GAAG4B,MAA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AAQc,sEACpBnF,IAAII,SAASE,UAAY+D,QAAQvE,OAAOuE,QAAQxB,IAAI,EAChDwB,SACArE,IAAIU,gBAAkB2D,QACtBrE,IAAIW,iBAAmB,KACvBX,IAAIY,kBAAmB,iBAClB,CAAC,CACFQ,WAAY,yCACZC,KAAM,CAAEkE,OAAQlB,QAAQxB,GAAI2C,YAAaxF,IAAII,SAASC,WACtD,GAAGkB,MAAK,SAASC,UACjBxB,IAAIW,kBAAmB,wCAAiBa,UAAS,GACjDxB,IAAIO,mBAAqBP,IAAIW,iBAC7BX,IAAIY,kBAAmB,EACnBuE,aACA7C,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,GAAK,IAAMwB,QAAQxB,OAEnEE,OAAM,SAASuC,6BACDrC,UAAUqC,OACvBtF,IAAIY,kBAAmB,WAGtB6E,aAAaN,aAG1BM,mBAAaN,sEACTnF,IAAII,SAASE,UAAY,EACzBN,IAAIU,gBAAkB,KACtBV,IAAIW,iBAAmB,KACvBX,IAAIO,mBAAqBP,IAAIQ,gBACzB2E,aACA7C,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,gcAvP3D6C,IAAIC,8CAGJD,IAAIE,oCAGJF,IAAIG,iCAEJH,IAAII,2BAGJ/B,MAAQ,IAAIgC,kBAAS,uBAErBhF,SAAU,8BAAa,CACvBC,UAAW,CACP6C,6BAA8B"} \ No newline at end of file diff --git a/amd/build/report-viewer-components.min.js b/amd/build/report-viewer-components.min.js index 70e18e8..4b854f9 100644 --- a/amd/build/report-viewer-components.min.js +++ b/amd/build/report-viewer-components.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/report-viewer-components",["exports","./simpleline/simpleline","core/str","./util/string-helper","./util/date-helper","core/ajax","core/notification","./util/svgarc","./util/debugger","core/config","./studyplan-processor","./treestudyplan-components","./util/premium","./util/fittext-vue"],(function(_exports,_simpleline,_str,_stringHelper,_dateHelper,_ajax,_notification,_svgarc,_debugger,_config,_studyplanProcessor,_treestudyplanComponents,_premium,_fittextVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_notification=_interopRequireDefault(_notification),_debugger=_interopRequireDefault(_debugger),_config=_interopRequireDefault(_config),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_fittextVue=_interopRequireDefault(_fittextVue);const π=Math.PI,ENROLLABLE_SELF=1,ENROLLABLE_ROLE=2,ENROLLABLE_SELF_ROLE=3;var _default={install(Vue){Vue.use(_treestudyplanComponents.default),Vue.use(_fittextVue.default);new _debugger.default("treestudyplan-viewer");let lastCaller=null;function scrollCurrentIntoView(handle){const elCurrentHeader=document.querySelector(".r-studyplan-scrollable").querySelector(".s-studyline-header-period.current");!elCurrentHeader||handle&&handle==lastCaller||(lastCaller=handle,elCurrentHeader.scrollIntoView({behavior:"smooth",block:"start",inline:"center"}))}let strings=(0,_stringHelper.load_strings)({report:{loading:"loadinghelp@core",studyplan_past:"studyplan_past",studyplan_present:"studyplan_present",studyplan_future:"studyplan_future",back:"back"},invalid:{error:"error"},grading:{ungraded:"ungraded",graded:"graded",allgraded:"allgraded",unsubmitted:"unsubmitted",nogrades:"nogrades",unknown:"unknown"},completion:{completed:"completion_completed",incomplete:"completion_incomplete",completed_pass:"completion_passed",completed_fail:"completion_failed",ungraded:"ungraded",aggregation_all:"aggregation_all",aggregation_any:"aggregation_any",aggregation_one:"aggregation_one",aggregation_overall_all:"aggregation_overall_all",aggregation_overall_any:"aggregation_overall_any",aggregation_overall_one:"aggregation_overall_one",completion_not_configured:"completion_not_configured",configure_completion:"configure_completion",view_completion_report:"view_completion_report",completion_incomplete:"completion_incomplete",completion_failed:"completion_failed",completion_pending:"completion_pending",completion_progress:"completion_progress",completion_completed:"completion_completed",completion_good:"completion_good",completion_excellent:"completion_excellent",view_feedback:"view_feedback",coursetiming_past:"coursetiming_past",coursetiming_present:"coursetiming_present",coursetiming_future:"coursetiming_future",required_goal:"required_goal",student_not_tracked:"student_not_tracked",completion_not_enabled:"completion_not_enabled"},badge:{share_badge:"share_badge",dateissued:"dateissued",dateexpire:"dateexpire",badgeinfo:"badgeinfo",badgeissuedstats:"badgeissuedstats",completion_incomplete:"completion_incomplete_badge",completion_completed:"completion_completed_badge",badgedisabled:"badgedisabled"},course:{completion_incomplete:"completion_incomplete",completion_failed:"completion_failed",completion_pending:"completion_pending",completion_progress:"completion_progress",completion_completed:"completion_completed",completion_good:"completion_good",completion_excellent:"completion_excellent",view_feedback:"view_feedback",coursetiming_past:"coursetiming_past",coursetiming_present:"coursetiming_present",coursetiming_future:"coursetiming_future",required_goal:"required_goal",student_not_tracked:"student_not_tracked",not_enrolled:"not_enrolled",noenddate:"noenddate"},teachercourse:{select_conditions:"select_conditions",select_grades:"select_grades",coursetiming_past:"coursetiming_past",coursetiming_present:"coursetiming_present",coursetiming_future:"coursetiming_future",grade_include:"grade_include",grade_require:"grade_require",required_goal:"required_goal",student_from_plan_enrolled:"student_from_plan_enrolled",students_from_plan_enrolled:"students_from_plan_enrolled",noenddate:"noenddate"},competency:{competency_not_configured:"competency_not_configured",configure_competency:"configure_competency",when:"when",required:"required",points:"points@core_grades",heading:"competency_heading",details:"competency_details",results:"results",unrated:"unrated",progress:"completion_progress",view_feedback:"view_feedback"},pageinfo:{edit:"period_edit",fullname:"studyplan_name",shortname:"studyplan_shortname",startdate:"studyplan_startdate",enddate:"studyplan_enddate",description:"studyplan_description",duration:"studyplan_duration",details:"studyplan_details",overview:"overviewreport:all",oveviewperiod:"overviewreport:period"},lineheader:{cannot_enrol:"line_cannot_enrol",can_enrol:"line_can_enrol",is_enrolled:"line_is_enrolled",enrol:"line_enrol",unenrol:"line_unenrol",enrolled:"line_enrolled",notenrolled:"line_notenrolled",enrol_question:"line_enrol_question",enrollments:"line_enrollments",enrollment:"line_enrollment",info:"info@core",confirm:"confirm@core",yes:"yes@core",no:"no@core",enrolled_in:"line_enrolled_in",since:"since@core",byname:"byname@core",students:"students@core",firstname:"firstname@core",lastname:"lastname@core",email:"email@core",enrol_student_question:"line_enrol_student_question",unenrol_student_question:"line_unenrol_student_question"}});function isVisible(elem){return!!(elem.offsetWidth||elem.offsetHeight||elem.getClientRects().length)}const ItemEventBus=new Vue;Vue.component("r-progress-circle",{props:{value:{type:Number},max:{type:Number,default:100},min:{type:Number,default:0},stroke:{type:Number,default:.2},bgopacity:{type:Number,default:.2},title:{type:String,default:""},icon:{type:String}},data:()=>({selectedstudyplan:null}),computed:{range(){return this.max-this.min},fraction(){return this.max-this.min==0?0:(this.value-this.min)/(this.max-this.min)},radius(){return 50-50*this.stroke},arcpath(){let fraction=0;const r=50-50*this.stroke;this.max-this.min!=0&&(fraction=(this.value-this.min)/(this.max-this.min));const Δ=2*fraction*π;return(0,_svgarc.svgarcpath)([50,50],[r,r],[0,Δ],1.5*π)}},methods:{},template:'\n
\n \n {{title}}\n \n \n \n \n \n \n \n
\n '}),Vue.component("r-report",{props:{invitekey:{type:String,default:()=>null},userid:{type:Number,default:()=>0},type:{type:String,default:()=>"own"}},data:()=>({text:strings.report,studyplans:{past:[],present:[],future:[]},selectedstudyplan:null,loadingstudyplan:!1,loading:!0}),computed:{teachermode(){return"teaching"==this.type},guestmode(){return"invited"==this.type},verified_type(){return["invited","other","teaching","own"].includes(this.type)?this.type:"own"},studyplancount(){return this.studyplans.past.length+this.studyplans.present.length+this.studyplans.future.length}},updated(){},mounted(){this.loadStudyplans()},methods:{call_args(o){const args={};return"object"!=typeof o||Array.isArray(o)||null===o||(0,_studyplanProcessor.objCopy)(args,o),"invited"==this.verified_type?args.invitekey=this.invitekey:"other"==this.verified_type&&(args.userid=this.userid),args},loadStudyplans(){const self=this;this.loading=!0,(0,_ajax.call)([{methodname:`local_treestudyplan_list_${this.verified_type}_studyplans`,args:this.call_args()}])[0].then((function(response){console.info("Loaded: plans",response);const plans={future:[],present:[],past:[]};for(const ix in response){const plan=response[ix];plans[(0,_dateHelper.studyplanTiming)(plan)].push(plan)}for(const ix in plans)plans[ix].sort(((a,b)=>{const t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime();return 0==t&&(t=a.name.localeCompare(b.name)),t}));self.studyplans=plans,self.loading=!1;const parts=window.location.hash.replace("#","").split("-");if(parts&&parts.length>0)for(const k in self.studyplans){const list=self.studyplans[k];for(const idx in list){const plan=list[idx];if(plan.id==parts[0]&&!plan.suspended)return void self.selectStudyplan(plan)}}if(1==this.studyplancount)if(self.studyplans.present.length>0){const plan=self.studyplans.present[0];plan.suspended||self.selectStudyplan(plan)}else if(self.studyplans.future.lengh>0){const plan=self.studyplans.future[0];plan.suspended||self.selectStudyplan(plan)}else{const plan=self.studyplans.past[0];plan.suspended||self.selectStudyplan(plan)}})).catch(_notification.default.exception)},selectStudyplan(plan){const self=this;this.loadingstudyplan=!0,(0,_ajax.call)([{methodname:`local_treestudyplan_get_${this.verified_type}_studyplan`,args:this.call_args({studyplanid:plan.id})}])[0].then((function(response){self.selectedstudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response),self.loadingstudyplan=!1,window.location.hash=self.selectedstudyplan.id})).catch(_notification.default.exception)},deselectStudyplan(){this.selectedstudyplan=null,this.loadStudyplans(),window.location.hash=""}},template:"\n
\n
\n \n
\n "}),Vue.component("r-studyplan",{props:{value:{type:Object},guestmode:{type:Boolean,default:!1},teachermode:{type:Boolean,default:!1},coaching:{type:Boolean,default:!1}},data:()=>({selectedpageindex:-1,text:strings.pageinfo}),computed:{selectedpage(){return this.value.pages[this.selectedpageindex]},startpageindex(){let startpageindex=0,firststart=null;for(const ix in this.value.pages){const page=this.value.pages[ix];if("present"==(0,_dateHelper.studyplanPageTiming)(page)){const s=new Date(page.startdate);(!firststart||firststart>s)&&(startpageindex=ix,firststart=s)}}return startpageindex},wwwroot:()=>_config.default.wwwroot},methods:{pageduration:page=>(0,_dateHelper.format_date)(page.startdate,!1)+" - "+(0,_dateHelper.format_date)(page.enddate,!1),columns:page=>1+2*page.periods,columns_stylerule(page){let s="grid-template-columns: var(--studyplan-filter-width)";for(let i=0;imaxLayer&&(maxLayer=item.layer)}for(const ix in line.slots[i].filters){const item=line.slots[i].filters[ix];item.layer>maxLayer&&(maxLayer=item.layer)}}return maxLayer>=0?maxLayer+1:1},showslot(page,line,index,layeridx,type){const forGradable="gradable"==type,periods=page.periods;let show=!0;for(let i=0;i0&&item.span-i>0&&(show=!1):item.span-i>1&&(show=!1))}}return show},selectedpageChanged(newTabIndex,prevTabIndex){ItemEventBus.$emit("redrawLines",null),scrollCurrentIntoView(this.selectedpage.id)}},mounted(){this.$root.$emit("redrawLines")},updated(){scrollCurrentIntoView(this.selectedpage.id),ItemEventBus.$emit("lineHeightChange",null),this.$root.$emit("redrawLines"),ItemEventBus.$emit("redrawLines")},template:'\n
\n \n \n \n \n \n \n \n \n {{ text.shortname}}\n \n {{ page.shortname }}\n \n \n \n {{ text.duration}}\n \n {{ pageduration(page) }}\n \n \n \n {{ text.description}}\n \n \n \n \n \n \n \n \n