1 line
16 KiB
Plaintext
1 line
16 KiB
Plaintext
{"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,MA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