1 line
12 KiB
Plaintext
1 line
12 KiB
Plaintext
{"version":3,"file":"page-view-plan copy.min.js","sources":["../src/page-view-plan copy.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';\nimport Vue from './vue';\n\nimport Debugger from './debugger';\nimport {load_strings} from './string-helper';\nimport {ProcessStudyplan, fixLineWrappers} from './studyplan-processor';\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport RVComponents from './report-viewer-components';\nVue.use(RVComponents);\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\n\nimport PortalVue from './portal-vue';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue';\nVue.use(BootstrapVue);\n\n\nlet debug = new Debugger(\"treestudyplanviewer\");\ndebug.enable();\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 */\n export function init(contextid,categoryid) {\n // Make sure the id's are numeric and integer\n if(undefined === contextid || !Number.isInteger(contextid) || contextid < 1 ){ contextid = 1;}\n if(undefined === categoryid || !Number.isInteger(categoryid)){ categoryid = 0;}\n\n const in_systemcontext = (contextid <= 1);\n\n window.addEventListener('resize',fixLineWrappers);\n let app = new Vue({\n el: '#root',\n data: {\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 created() {\n this.$root.$on('redrawLines',()=>{\n // Ugly hack, but currently the only way to properly fix scrollablility in the lines\n fixLineWrappers();\n });\n },\n updated() {\n // Ugly hack, but currently the only way to properly fix scrollablility in the lines\n setTimeout(fixLineWrappers, 50);\n },\n async mounted() {\n fixLineWrappers();\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: {context_id: contextid}\n }])[0].done(function(response){\n const timingval = { present: 0, past: 1, future: 2};\n response.sort((a,b) => {\n const timinga = TSComponents.studyplanTiming(a);\n const timingb = TSComponents.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 = location.hash.replace('#','');\n const parts = hash.split(\"-\");\n\n if(!!parts && parts.length > 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 }).fail(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_used_categories',\n args: { operation: 'view'}\n }])[0].done(function(response){\n const contexts = [];\n for(const ix in response){\n if(response[ix].studyplancount >0){\n contexts.push(response[ix]);\n }\n }\n app.usedcontexts = contexts;\n }).fail(notification.exception);\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 switchContext(ctx){\n const params = new URLSearchParams(location.search);\n params.set('categoryid', ctx.id);\n window.location.search = params.toString();\n\n },\n closeStudyplan() {\n app.activestudyplan = null;\n app.associatedstudents = [];\n app.studentstudyplan = [];\n app.displayedstudyplan = null;\n },\n\n selectStudyplan(studyplan,studentid){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = null;\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].done(function(response){\n app.activestudyplan = ProcessStudyplan(response,true);\n app.displayedstudyplan = app.activestudyplan;\n app.loadingstudyplan = false;\n location.hash = app.activestudyplan.id;\n call([{\n methodname: 'local_treestudyplan_all_associated',\n args: { studyplan_id: studyplan.id}\n }])[0].done(function(response){\n app.associatedstudents = response;\n if(studentid){\n for(const student of app.associatedstudents){\n if(student.id == studentid){\n app.showStudentView(student);\n break;\n }\n }\n }\n }).fail(notification.exception);\n\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n showStudentView(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].done(function(response){\n app.studentstudyplan = ProcessStudyplan(response,false);\n app.displayedstudyplan = app.studentstudyplan;\n app.loadingstudyplan = false;\n location.hash = app.activestudyplan.id + \"-\" + student.id;\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n\n\n },\n showOverview(){\n app.selectedstudent = null;\n app.studentstudyplan = null;\n app.displayedstudyplan = app.activestudyplan;\n }\n\n },\n });\n}\n"],"names":["contextid","categoryid","undefined","Number","isInteger","window","addEventListener","fixLineWrappers","app","Vue","el","data","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","studyplan","toolbox","right","usedcontexts","created","_this","$root","$on","updated","setTimeout","mounted","methodname","args","context_id","done","response","timingval","present","past","future","sort","a","b","timinga","TSComponents","studyplanTiming","timingb","t","name","localeCompare","parts","location","hash","replace","split","length","idx","id","selectStudyplan","fail","notification","exception","operation","contexts","ix","studyplancount","push","computed","dropdown_title","this","studyplan_select_placeholder","methods","switchContext","ctx","params","URLSearchParams","search","set","toString","closeStudyplan","studentid","studyplan_id","student","showStudentView","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","enable"],"mappings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