From 65c9537bd3d8b298d202c5591dac86d070cf864f Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Thu, 15 Aug 2024 14:41:43 +0200 Subject: [PATCH] Disabled display of student name when only one student is in the plan --- amd/build/page-coach.min.js | 2 +- amd/build/page-coach.min.js.map | 2 +- amd/src/page-coach.js | 7 +++++++ coach.php | 3 ++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/amd/build/page-coach.min.js b/amd/build/page-coach.min.js index 2f82ab0..0bd4d97 100644 --- a/amd/build/page-coach.min.js +++ b/amd/build/page-coach.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-coach",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-processor","./util/date-helper","./util/browserbuttonevents","./studyplan-editor-components","./treestudyplan-components","./report-viewer-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_browserbuttonevents,_studyplanEditorComponents,_treestudyplanComponents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){let app=new _vue.default({el:"#root",data:{selected:{planid:0,studentid:0},displayedstudyplan:null,activestudyplan:null,associatedstudents:[],selectedstudent:null,studentstudyplan:null,loadingstudyplan:!1,studyplans:[],text:strings.coach,toolbox:{right:!0},usedcontexts:[],editmode:!1},async mounted(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_coaching_studyplans",args:{}}])[0].then((function(response){const timingval={present:0,past:1,future:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b),t=timingval[timinga]-timingval[timingb];return 0==t?a.name.localeCompare(b.name):t})),app.studyplans=response;const parts=window.location.hash.replace("#","").split("-");if(parts&&parts.length>0&&""!=parts[0])for(let idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1],!1);break}})).catch(_notification.default.exception),(0,_browserbuttonevents.addBrowserButtonEvent)(this.navChanged,this.navChanged)},computed:{},methods:{navChanged(){const hash=window.location.hash.replace("#",""),parts=hash.split("-");if(debug.log("Navigation changed",hash,parts),parts&&parts.length>0){const planid=Number(parts[0]),studentid=parts.length>1?Number(parts[1]):0;if(debug.log("Selected ids",planid,studentid,this.selected.planid,this.selected.studentid),0==planid)planid!=this.selected.planid&&this.closeStudyplan(!1);else if(this.selected.planid!=planid||0==studentid&&0!=this.selected.studentid){debug.info("Requested plan changed - loading studyplan");for(let idx in app.studyplans){const plan=this.studyplans[idx];if(Number(plan.id)==planid){this.selectStudyplan(plan,studentid,!1);break}}}else if(this.selected.studentid!=studentid)for(const group of app.associatedstudents)for(const student of group.users)if(Number(student.id)==studentid){app.showStudentView(student,!1);break}}},closeStudyplan(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];app.selected.planid=0,app.selected.studentid=0,app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,updatehash&&(window.location.hash="")},selectStudyplan(studyplan,studentid){let updatehash=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];app.selected.planid=Number(studyplan.id),app.selected.studentid=studentid?Number(studentid):0;const self=this;self.loadingstudyplan=!0,self.associatedstudents=[],self.selectedstudent=null,self.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].then((response=>{self.activestudyplan=(0,_studyplanProcessor.processStudyplan)(response,!0),(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated_grouped",args:{studyplan_id:studyplan.id}}])[0].then((function(response){self.associatedstudents=response;let foundstudent=!1;if(studentid)for(const group of self.associatedstudents)for(const student of group.users)if(student.id==studentid){foundstudent=!0,self.showStudentView(student);break}if(!foundstudent)for(const group of self.associatedstudents)for(const student of group.users){foundstudent=!0,self.showStudentView(student);break}foundstudent||(app.selected.studentid=0,updatehash&&(window.location.hash=app.activestudyplan.id),self.displayedstudyplan=self.activestudyplan,self.loadingstudyplan=!1)})).catch(_notification.default.exception)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){let updatehash=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];app.selected.studentid=student?Number(student.id):0,student?(app.selectedstudent=student,app.studentstudyplan=null,app.loadingstudyplan=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_get_user_studyplan",args:{userid:student.id,studyplanid:app.activestudyplan.id}}])[0].then((response=>{app.studentstudyplan=(0,_studyplanProcessor.processStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,updatehash&&(window.location.hash=app.activestudyplan.id+"-"+student.id)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))):this.showOverview(updatehash)},showOverview(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];debug.info("Switch to overview",updatehash),app.selected.studentid=0,app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,updatehash&&(window.location.hash=app.activestudyplan.id)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);let debug=new _debugger.default("treestudyplancoach"),strings=(0,_stringHelper.loadStrings)({coach:{}})})); +define("local_treestudyplan/page-coach",["exports","core/ajax","core/notification","./vue/vue","./util/debugger","./util/string-helper","./studyplan-processor","./util/date-helper","./util/browserbuttonevents","./studyplan-editor-components","./treestudyplan-components","./report-viewer-components","./modedit-modal","./portal-vue/portal-vue.esm","./bootstrap-vue/bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_dateHelper,_browserbuttonevents,_studyplanEditorComponents,_treestudyplanComponents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(){let app=new _vue.default({el:"#root",data:{selected:{planid:0,studentid:0},displayedstudyplan:null,activestudyplan:null,associatedstudents:[],selectedstudent:null,studentstudyplan:null,loadingstudyplan:!1,studyplans:[],text:strings.coach,toolbox:{right:!0},usedcontexts:[],editmode:!1},async mounted(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_coaching_studyplans",args:{}}])[0].then((function(response){const timingval={present:0,past:1,future:2};response.sort(((a,b)=>{const timinga=(0,_dateHelper.studyplanTiming)(a),timingb=(0,_dateHelper.studyplanTiming)(b),t=timingval[timinga]-timingval[timingb];return 0==t?a.name.localeCompare(b.name):t})),app.studyplans=response;const parts=window.location.hash.replace("#","").split("-");if(parts&&parts.length>0&&""!=parts[0])for(let idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1],!1);break}})).catch(_notification.default.exception),(0,_browserbuttonevents.addBrowserButtonEvent)(this.navChanged,this.navChanged)},computed:{studentcount(){let count=0;for(const group of app.associatedstudents)count+=group.users.length;return count}},methods:{navChanged(){const hash=window.location.hash.replace("#",""),parts=hash.split("-");if(debug.log("Navigation changed",hash,parts),parts&&parts.length>0){const planid=Number(parts[0]),studentid=parts.length>1?Number(parts[1]):0;if(debug.log("Selected ids",planid,studentid,this.selected.planid,this.selected.studentid),0==planid)planid!=this.selected.planid&&this.closeStudyplan(!1);else if(this.selected.planid!=planid||0==studentid&&0!=this.selected.studentid){debug.info("Requested plan changed - loading studyplan");for(let idx in app.studyplans){const plan=this.studyplans[idx];if(Number(plan.id)==planid){this.selectStudyplan(plan,studentid,!1);break}}}else if(this.selected.studentid!=studentid)for(const group of app.associatedstudents)for(const student of group.users)if(Number(student.id)==studentid){app.showStudentView(student,!1);break}}},closeStudyplan(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];app.selected.planid=0,app.selected.studentid=0,app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null,updatehash&&(window.location.hash="")},selectStudyplan(studyplan,studentid){let updatehash=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];app.selected.planid=Number(studyplan.id),app.selected.studentid=studentid?Number(studentid):0;const self=this;self.loadingstudyplan=!0,self.associatedstudents=[],self.selectedstudent=null,self.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].then((response=>{self.activestudyplan=(0,_studyplanProcessor.processStudyplan)(response,!0),(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated_grouped",args:{studyplan_id:studyplan.id}}])[0].then((function(response){self.associatedstudents=response;let foundstudent=!1;if(studentid)for(const group of self.associatedstudents)for(const student of group.users)if(student.id==studentid){foundstudent=!0,self.showStudentView(student);break}if(!foundstudent)for(const group of self.associatedstudents)for(const student of group.users){foundstudent=!0,self.showStudentView(student);break}foundstudent||(app.selected.studentid=0,updatehash&&(window.location.hash=app.activestudyplan.id),self.displayedstudyplan=self.activestudyplan,self.loadingstudyplan=!1)})).catch(_notification.default.exception)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView(student){let updatehash=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];app.selected.studentid=student?Number(student.id):0,student?(app.selectedstudent=student,app.studentstudyplan=null,app.loadingstudyplan=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_get_user_studyplan",args:{userid:student.id,studyplanid:app.activestudyplan.id}}])[0].then((response=>{app.studentstudyplan=(0,_studyplanProcessor.processStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,updatehash&&(window.location.hash=app.activestudyplan.id+"-"+student.id)})).catch((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))):this.showOverview(updatehash)},showOverview(){let updatehash=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];debug.info("Switch to overview",updatehash),app.selected.studentid=0,app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan,updatehash&&(window.location.hash=app.activestudyplan.id)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default);let debug=new _debugger.default("treestudyplancoach"),strings=(0,_stringHelper.loadStrings)({coach:{}})})); //# 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 d3e4409..ba8ebf3 100644 --- a/amd/build/page-coach.min.js.map +++ b/amd/build/page-coach.min.js.map @@ -1 +1 @@ -{"version":3,"file":"page-coach.min.js","sources":["../src/page-coach.js"],"sourcesContent":["/* eslint no-var: \"error\" */\n/* eslint no-unused-vars: \"off\" */\n/* eslint linebreak-style: \"off\" */\n/* eslint no-trailing-spaces: \"off\" */\n/* eslint promise/no-nesting: \"off\" */\n/* eslint max-depth: [\"error\", 6]*/\n/* eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplancoach\");\n\nlet strings = loadStrings({\n coach: {\n },\n});\n\n/**\n * Initialize the Page\n */\nexport function init() {\n let app = new Vue({\n el: '#root',\n data: {\n selected: {\n planid: 0,\n studentid: 0,\n },\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.coach,\n toolbox: {\n right: true,\n },\n usedcontexts: [],\n editmode: false,\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_coaching_studyplans',\n args: {}\n }])[0].then(function(response) {\n const timingval = {present: 0, past: 1, future: 2};\n response.sort((a, b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n\n const t = timingval[timinga] - timingval[timingb];\n if (t == 0) {\n // Sort by name if timing is equal\n return a.name.localeCompare(b.name);\n } else {\n return t;\n }\n });\n app.studyplans = response;\n // Load studyplan from hash if applicable\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n\n if (!!parts && parts.length > 0 && parts[0] != '') {\n for (let idx in app.studyplans) {\n if (app.studyplans[idx].id == parts[0]) {\n app.selectStudyplan(app.studyplans[idx], parts[1], false);\n break;\n }\n }\n }\n return;\n }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\n },\n methods: {\n navChanged() {\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n debug.log(\"Navigation changed\", hash, parts);\n\n if (!!parts && parts.length > 0) {\n const planid = Number(parts[0]);\n const studentid = (parts.length > 1) ? Number(parts[1]) : 0;\n\n debug.log(\"Selected ids\", planid, studentid, this.selected.planid, this.selected.studentid);\n if (planid == 0) {\n if (planid != this.selected.planid) {\n this.closeStudyplan(false);\n }\n } else if (this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0)) {\n debug.info(\"Requested plan changed - loading studyplan\");\n for (let idx in app.studyplans) {\n const plan = this.studyplans[idx];\n if (Number(plan.id) == planid) {\n this.selectStudyplan(plan, studentid, false);\n break;\n }\n }\n } else if (this.selected.studentid != studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (Number(student.id) == studentid) {\n app.showStudentView(student, false);\n break;\n }\n }\n }\n }\n }\n },\n closeStudyplan(updatehash = true) {\n app.selected.planid = 0;\n app.selected.studentid = 0;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n if (updatehash) {\n window.location.hash = '';\n }\n },\n\n selectStudyplan(studyplan, studentid, updatehash = true) {\n app.selected.planid = Number(studyplan.id);\n app.selected.studentid = studentid ? Number(studentid) : 0;\n // Fetch studyplan\n const self = this;\n self.loadingstudyplan = true;\n self.associatedstudents = [];\n self.selectedstudent = null;\n self.studentstudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: {id: studyplan.id}\n }])[0].then((response) => {\n self.activestudyplan = processStudyplan(response, true);\n\n call([{\n methodname: 'local_treestudyplan_all_associated_grouped',\n args: {'studyplan_id': studyplan.id}\n }])[0].then(function(response) {\n self.associatedstudents = response;\n let foundstudent = false;\n if (studentid) {\n for (const group of self.associatedstudents) {\n for (const student of group.users) {\n if (student.id == studentid) {\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n }\n if (!foundstudent) {\n // Select first student available.\n for (const group of self.associatedstudents) {\n for (const student of group.users) {\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n if (!foundstudent) {\n // Update hash with just the studyplan if no student was available for display\n app.selected.studentid = 0;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n self.displayedstudyplan = self.activestudyplan;\n self.loadingstudyplan = false;\n }\n return;\n }).catch(notification.exception);\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student, updatehash = true) {\n app.selected.studentid = student ? Number(student.id) : 0;\n if (student) {\n app.selectedstudent = student;\n app.studentstudyplan = null;\n app.loadingstudyplan = true;\n call([{\n methodname: 'local_treestudyplan_get_user_studyplan',\n args: {userid: student.id, studyplanid: app.activestudyplan.id}\n }])[0].then((response) => {\n app.studentstudyplan = processStudyplan(response, false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n } else {\n this.showOverview(updatehash);\n }\n },\n showOverview(updatehash = true) {\n debug.info(\"Switch to overview\", updatehash);\n app.selected.studentid = 0;\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n }\n\n },\n });\n}\n"],"names":["app","Vue","el","data","selected","planid","studentid","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","coach","toolbox","right","usedcontexts","editmode","methodname","args","then","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","catch","notification","exception","this","navChanged","computed","methods","debug","log","Number","closeStudyplan","info","plan","group","student","users","showStudentView","updatehash","studyplan","self","foundstudent","error","userid","studyplanid","showOverview","use","EditorComponents","TSComponents","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"ixBAkDQA,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,SAAU,CACNC,OAAQ,EACRC,UAAW,GAEfC,mBAAoB,KACpBC,gBAAiB,KACjBC,mBAAoB,GACpBC,gBAAiB,KACjBC,iBAAkB,KAClBC,kBAAkB,EAClBC,WAAY,GACZC,KAAMC,QAAQC,MACdC,QAAS,CACLC,OAAO,GAEXC,aAAc,GACdC,UAAU,kCAGL,CAAC,CACFC,WAAY,+CACZC,KAAM,MACN,GAAGC,MAAK,SAASC,gBACXC,UAAY,CAACC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GAChDJ,SAASK,MAAK,CAACC,EAAGC,WACRC,SAAU,+BAAgBF,GAC1BG,SAAU,+BAAgBF,GAE1BG,EAAIT,UAAUO,SAAWP,UAAUQ,gBAChC,GAALC,EAEOJ,EAAEK,KAAKC,cAAcL,EAAEI,MAEvBD,KAGflC,IAAIa,WAAaW,eAGXa,MADOC,OAAOC,SAASC,KAAKC,QAAQ,IAAK,IAC5BC,MAAM,QAEnBL,OAASA,MAAMM,OAAS,GAAiB,IAAZN,MAAM,OAChC,IAAIO,OAAO5C,IAAIa,cACZb,IAAIa,WAAW+B,KAAKC,IAAMR,MAAM,GAAI,CACpCrC,IAAI8C,gBAAgB9C,IAAIa,WAAW+B,KAAMP,MAAM,IAAI,aAMhEU,MAAMC,sBAAaC,0DACAC,KAAKC,WAAYD,KAAKC,aAEhDC,SAAU,GAEVC,QAAS,CACLF,mBACUX,KAAOF,OAAOC,SAASC,KAAKC,QAAQ,IAAK,IACzCJ,MAAQG,KAAKE,MAAM,QACzBY,MAAMC,IAAI,qBAAsBf,KAAMH,OAEhCA,OAASA,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IAAIU,gBAAkB,KACtBV,IAAIW,iBAAmB,KACvBX,IAAIO,mBAAqBP,IAAIQ,gBACzBwD,aACA1B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,8gBAjO3D2B,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,8CAGJH,IAAII,oCAGJJ,IAAIK,iCAEJL,IAAIM,2BAGJxB,MAAQ,IAAIyB,kBAAS,sBAErBhE,SAAU,6BAAY,CACtBC,MAAO"} \ No newline at end of file +{"version":3,"file":"page-coach.min.js","sources":["../src/page-coach.js"],"sourcesContent":["/* eslint no-var: \"error\" */\n/* eslint no-unused-vars: \"off\" */\n/* eslint linebreak-style: \"off\" */\n/* eslint no-trailing-spaces: \"off\" */\n/* eslint promise/no-nesting: \"off\" */\n/* eslint max-depth: [\"error\", 6]*/\n/* eslint-env es6*/\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplancoach\");\n\nlet strings = loadStrings({\n coach: {\n },\n});\n\n/**\n * Initialize the Page\n */\nexport function init() {\n let app = new Vue({\n el: '#root',\n data: {\n selected: {\n planid: 0,\n studentid: 0,\n },\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.coach,\n toolbox: {\n right: true,\n },\n usedcontexts: [],\n editmode: false,\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_coaching_studyplans',\n args: {}\n }])[0].then(function(response) {\n const timingval = {present: 0, past: 1, future: 2};\n response.sort((a, b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n\n const t = timingval[timinga] - timingval[timingb];\n if (t == 0) {\n // Sort by name if timing is equal\n return a.name.localeCompare(b.name);\n } else {\n return t;\n }\n });\n app.studyplans = response;\n // Load studyplan from hash if applicable\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n\n if (!!parts && parts.length > 0 && parts[0] != '') {\n for (let idx in app.studyplans) {\n if (app.studyplans[idx].id == parts[0]) {\n app.selectStudyplan(app.studyplans[idx], parts[1], false);\n break;\n }\n }\n }\n return;\n }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\n studentcount() {\n let count = 0;\n for (const group of app.associatedstudents) {\n count += group.users.length;\n }\n return count;\n }\n },\n methods: {\n navChanged() {\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n debug.log(\"Navigation changed\", hash, parts);\n\n if (!!parts && parts.length > 0) {\n const planid = Number(parts[0]);\n const studentid = (parts.length > 1) ? Number(parts[1]) : 0;\n\n debug.log(\"Selected ids\", planid, studentid, this.selected.planid, this.selected.studentid);\n if (planid == 0) {\n if (planid != this.selected.planid) {\n this.closeStudyplan(false);\n }\n } else if (this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0)) {\n debug.info(\"Requested plan changed - loading studyplan\");\n for (let idx in app.studyplans) {\n const plan = this.studyplans[idx];\n if (Number(plan.id) == planid) {\n this.selectStudyplan(plan, studentid, false);\n break;\n }\n }\n } else if (this.selected.studentid != studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (Number(student.id) == studentid) {\n app.showStudentView(student, false);\n break;\n }\n }\n }\n }\n }\n },\n closeStudyplan(updatehash = true) {\n app.selected.planid = 0;\n app.selected.studentid = 0;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n if (updatehash) {\n window.location.hash = '';\n }\n },\n\n selectStudyplan(studyplan, studentid, updatehash = true) {\n app.selected.planid = Number(studyplan.id);\n app.selected.studentid = studentid ? Number(studentid) : 0;\n // Fetch studyplan\n const self = this;\n self.loadingstudyplan = true;\n self.associatedstudents = [];\n self.selectedstudent = null;\n self.studentstudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: {id: studyplan.id}\n }])[0].then((response) => {\n self.activestudyplan = processStudyplan(response, true);\n\n call([{\n methodname: 'local_treestudyplan_all_associated_grouped',\n args: {'studyplan_id': studyplan.id}\n }])[0].then(function(response) {\n self.associatedstudents = response;\n let foundstudent = false;\n if (studentid) {\n for (const group of self.associatedstudents) {\n for (const student of group.users) {\n if (student.id == studentid) {\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n }\n if (!foundstudent) {\n // Select first student available.\n for (const group of self.associatedstudents) {\n for (const student of group.users) {\n foundstudent = true;\n self.showStudentView(student);\n break;\n }\n }\n }\n if (!foundstudent) {\n // Update hash with just the studyplan if no student was available for display\n app.selected.studentid = 0;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n self.displayedstudyplan = self.activestudyplan;\n self.loadingstudyplan = false;\n }\n return;\n }).catch(notification.exception);\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student, updatehash = true) {\n app.selected.studentid = student ? Number(student.id) : 0;\n if (student) {\n app.selectedstudent = student;\n app.studentstudyplan = null;\n app.loadingstudyplan = true;\n call([{\n methodname: 'local_treestudyplan_get_user_studyplan',\n args: {userid: student.id, studyplanid: app.activestudyplan.id}\n }])[0].then((response) => {\n app.studentstudyplan = processStudyplan(response, false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n } else {\n this.showOverview(updatehash);\n }\n },\n showOverview(updatehash = true) {\n debug.info(\"Switch to overview\", updatehash);\n app.selected.studentid = 0;\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n }\n\n },\n });\n}\n"],"names":["app","Vue","el","data","selected","planid","studentid","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","coach","toolbox","right","usedcontexts","editmode","methodname","args","then","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","catch","notification","exception","this","navChanged","computed","studentcount","count","group","users","methods","debug","log","Number","closeStudyplan","info","plan","student","showStudentView","updatehash","studyplan","self","foundstudent","error","userid","studyplanid","showOverview","use","EditorComponents","TSComponents","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"ixBAkDQA,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,SAAU,CACNC,OAAQ,EACRC,UAAW,GAEfC,mBAAoB,KACpBC,gBAAiB,KACjBC,mBAAoB,GACpBC,gBAAiB,KACjBC,iBAAkB,KAClBC,kBAAkB,EAClBC,WAAY,GACZC,KAAMC,QAAQC,MACdC,QAAS,CACLC,OAAO,GAEXC,aAAc,GACdC,UAAU,kCAGL,CAAC,CACFC,WAAY,+CACZC,KAAM,MACN,GAAGC,MAAK,SAASC,gBACXC,UAAY,CAACC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GAChDJ,SAASK,MAAK,CAACC,EAAGC,WACRC,SAAU,+BAAgBF,GAC1BG,SAAU,+BAAgBF,GAE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vBF,OAAM,SAASuB,6BACDrB,UAAUqB,OACvBtE,IAAIY,kBAAmB,MAG/BqD,gBAAgBD,aAASE,sEACrBlE,IAAII,SAASE,UAAY0D,QAAUJ,OAAOI,QAAQnB,IAAM,EACpDmB,SACAhE,IAAIU,gBAAkBsD,QACtBhE,IAAIW,iBAAmB,KACvBX,IAAIY,kBAAmB,iBAClB,CAAC,CACFS,WAAY,yCACZC,KAAM,CAACiD,OAAQP,QAAQnB,GAAI2B,YAAaxE,IAAIQ,gBAAgBqC,OAC5D,GAAGtB,MAAMC,WACTxB,IAAIW,kBAAmB,wCAAiBa,UAAU,GAClDxB,IAAIO,mBAAqBP,IAAIW,iBAC7BX,IAAIY,kBAAmB,EACnBsD,aACA5B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,GAAK,IAAMmB,QAAQnB,OAGnEE,OAAM,SAASuB,6BACDrB,UAAUqB,OACvBtE,IAAIY,kBAAmB,WAGtB6D,aAAaP,aAG1BO,mBAAaP,sEACTR,MAAMI,KAAK,qBAAsBI,YACjClE,IAAII,SAASE,UAAY,EACzBN,IAAIU,gBAAkB,KACtBV,IAAIW,iBAAmB,KACvBX,IAAIO,mBAAqBP,IAAIQ,gBACzB0D,aACA5B,OAAOC,SAASC,KAAOxC,IAAIQ,gBAAgBqC,8gBAxO3D6B,IAAIC,iDAGJD,IAAIE,+CAGJF,IAAIG,8CAGJH,IAAII,oCAGJJ,IAAIK,iCAEJL,IAAIM,2BAGJtB,MAAQ,IAAIuB,kBAAS,sBAErBlE,SAAU,6BAAY,CACtBC,MAAO"} \ No newline at end of file diff --git a/amd/src/page-coach.js b/amd/src/page-coach.js index f794608..7f9cdfb 100644 --- a/amd/src/page-coach.js +++ b/amd/src/page-coach.js @@ -105,6 +105,13 @@ export function init() { addBrowserButtonEvent(this.navChanged, this.navChanged); }, computed: { + studentcount() { + let count = 0; + for (const group of app.associatedstudents) { + count += group.users.length; + } + return count; + } }, methods: { navChanged() { diff --git a/coach.php b/coach.php index 110501a..62a0f13 100644 --- a/coach.php +++ b/coach.php @@ -94,7 +94,8 @@ print <<

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

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

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