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

1 line
16 KiB
Plaintext

{"version":3,"file":"page-view-plan.min.js","sources":["../src/page-view-plan.js"],"sourcesContent":["/* eslint no-unused-vars: \"off\" */\n/* eslint no-trailing-spaces: \"off\" */\n/* eslint max-depth: [\"error\", 5] */\n// Put this file in path/to/plugin/amd/src\n// You can call it anything you like\n\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\nimport Debugger from './util/debugger';\nimport {loadStrings} from './util/string-helper';\nimport {processStudyplan} from './studyplan-processor';\nimport {studyplanTiming} from './util/date-helper';\nimport {addBrowserButtonEvent} from './util/browserbuttonevents';\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplanviewer\");\n\nlet strings = loadStrings({\n studyplan: {\n studyplanSelectPlaceholder: 'studyplan_select_placeholder',\n },\n});\n\n/**\n * Initialize the Page\n * @param {number} contextid The context we should attempt to work in (1:1 related to the category)\n * @param {number} categoryid The category we shoud attempt to work in (1:1 related to the context)\n */\nexport function init(contextid, categoryid) {\n // Make sure the id's are numeric and integer\n if (undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1) {\n contextid = 1;\n } else { // Ensure a numeric value instead of string\n contextid = Number(contextid);\n }\n if (undefined === categoryid || !Number.isInteger(Number(categoryid))) {\n categoryid = 0;\n } else { // Ensure a numeric value instead of string\n categoryid = Number(categoryid);\n }\n\n let app = new Vue({\n el: '#root',\n data: {\n selected: {\n planid: 0,\n studentid: 0,\n },\n displayedstudyplan: null,\n activestudyplan: null,\n associatedstudents: [],\n selectedstudent: null,\n studentstudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n text: strings.studyplan,\n toolbox: {\n right: true,\n },\n usedcontexts: [],\n },\n async mounted() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: {'context_id': contextid}\n }])[0].then((response) => {\n const timingval = {present: 0, past: 1, future: 2};\n response.sort((a, b) => {\n const timinga = studyplanTiming(a);\n const timingb = studyplanTiming(b);\n\n const t = timingval[timinga] - timingval[timingb];\n if (t == 0) {\n // Sort by name if timing is equal\n return a.name.localeCompare(b.name);\n } else {\n return t;\n }\n });\n app.studyplans = response;\n // Load studyplan from hash if applicable\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n\n if (!!parts && parts.length > 0 && parts[0] != '') {\n for (let idx in app.studyplans) {\n if (app.studyplans[idx].id == parts[0]) {\n app.selectStudyplan(app.studyplans[idx], parts[1]);\n break;\n }\n }\n }\n return;\n }).catch(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_available_categories',\n args: {operation: 'view', 'refcontext_id': contextid}\n }])[0].then((response) => {\n const contexts = [];\n for (const ix in response) {\n const cat = response[ix];\n if (cat.studyplancount > 0 || cat.context_id == contextid) {\n contexts.push(cat);\n }\n }\n app.usedcontexts = contexts;\n return;\n }).catch(notification.exception);\n addBrowserButtonEvent(this.navChanged, this.navChanged);\n },\n computed: {\n dropdownTitle() {\n if (this.activestudyplan && this.activestudyplan.name) {\n return this.activestudyplan.name;\n } else {\n return this.text.studyplanSelectPlaceholder;\n }\n },\n contextid() {\n return contextid;\n }\n },\n methods: {\n navChanged() {\n const hash = window.location.hash.replace('#', '');\n const parts = hash.split(\"-\");\n debug.log(\"Navigation changed\", hash, parts);\n\n if (!!parts && parts.length > 0) {\n const planid = Number(parts[0]);\n const studentid = (parts.length > 1) ? Number(parts[1]) : 0;\n\n debug.log(\"Selected ids\", planid, studentid, this.selected.planid, this.selected.studentid);\n if (planid == 0) {\n if (planid != this.selected.planid) {\n this.closeStudyplan(false);\n }\n } else if (this.selected.planid != planid || (studentid == 0 && this.selected.studentid != 0)) {\n debug.info(\"Requested plan changed - loading studyplan\");\n for (let idx in app.studyplans) {\n const plan = this.studyplans[idx];\n if (Number(plan.id) == planid) {\n this.selectStudyplan(plan, studentid, false);\n break;\n }\n }\n } else if (this.selected.studentid != studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (Number(student.id) == studentid) {\n app.showStudentView(student, false);\n break;\n }\n }\n }\n }\n } \n },\n switchContext(ctxid) {\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set('contextid', ctxid);\n setTimeout(() => {\n // Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.\n window.location.href = window.location.pathname + \"?\" + params.toString();\n }, 50);\n },\n closeStudyplan(updatehash = true) {\n app.selected.planid = 0;\n app.selected.studentid = 0;\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n if (updatehash) {\n window.location.hash = '';\n }\n },\n\n selectStudyplan(studyplan, studentid, updatehash = true) {\n app.selected.planid = Number(studyplan.id);\n app.selected.studentid = studentid ? Number(studentid) : 0;\n // Fetch studyplan\n app.loadingstudyplan = true;\n app.associatedstudents = [];\n app.selectedstudent = null;\n app.studentstudyplan = null;\n call([{\n methodname: 'local_treestudyplan_get_studyplan_map',\n args: {id: studyplan.id}\n }])[0].then((response) => {\n app.activestudyplan = processStudyplan(response, true);\n \n call([{\n methodname: 'local_treestudyplan_all_associated_grouped',\n args: {'studyplan_id': studyplan.id}\n }])[0].then((response) => {\n app.associatedstudents = response;\n let foundstudent = false;\n if (studentid) {\n for (const group of app.associatedstudents) {\n for (const student of group.users) {\n if (student.id == studentid) {\n foundstudent = true;\n app.showStudentView(student, updatehash);\n break;\n }\n }\n }\n }\n if (!foundstudent) {\n app.selected.studentid = 0;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n app.displayedstudyplan = app.activestudyplan;\n app.loadingstudyplan = false;\n }\n return;\n }).catch(notification.exception);\n return;\n }).catch(function(error) {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(student, updatehash = true) {\n app.selected.studentid = student ? Number(student.id) : 0;\n if (student) {\n app.selectedstudent = student;\n app.studentstudyplan = null;\n app.loadingstudyplan = true;\n call([{\n methodname: 'local_treestudyplan_get_user_studyplan',\n args: {userid: student.id, studyplanid: app.selected.planid}\n }])[0].then((response) => {\n app.studentstudyplan = processStudyplan(response, false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id + \"-\" + student.id;\n }\n return;\n }).catch((error) => {\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n } else {\n this.showOverview(updatehash);\n }\n },\n showOverview(updatehash = true) {\n app.selected.studentid = 0;\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n if (updatehash) {\n window.location.hash = app.activestudyplan.id;\n }\n }\n\n },\n });\n}\n"],"names":["contextid","categoryid","undefined","Number","isInteger","app","Vue","el","data","selected","planid","studentid","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","studyplan","toolbox","right","usedcontexts","methodname","args","then","response","timingval","present","past","future","sort","a","b","timinga","timingb","t","name","localeCompare","parts","window","location","hash","replace","split","length","idx","id","selectStudyplan","catch","notification","exception","operation","contexts","ix","cat","studyplancount","context_id","push","this","navChanged","computed","dropdownTitle","studyplanSelectPlaceholder","methods","debug","log","closeStudyplan","info","plan","group","student","users","showStudentView","switchContext","ctxid","params","URLSearchParams","search","delete","set","setTimeout","href","pathname","toString","updatehash","foundstudent","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger"],"mappings":"8pBAyCqBA,UAAWC,YAGxBD,eADAE,IAAcF,YAAcG,OAAOC,UAAUD,OAAOH,aAAeA,UAAY,EACnE,EAEAG,OAAOH,WAKnBC,gBAHAC,IAAcD,YAAeE,OAAOC,UAAUD,OAAOF,aAGxCE,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