moodle_local_treestudyplan/amd/build/page-coach.min.js.map
2024-06-03 23:24:16 +02:00

1 line
14 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 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":"ixBAiDQA,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,IAA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