1 line
15 KiB
Plaintext
1 line
15 KiB
Plaintext
{"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,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,WAA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