2024-02-09 14:48:15 +01:00
|
|
|
/*eslint no-var: "error" */
|
|
|
|
/*eslint no-unused-vars: "off" */
|
|
|
|
/*eslint linebreak-style: "off" */
|
|
|
|
/*eslint no-trailing-spaces: "off" */
|
|
|
|
/*eslint-env es6*/
|
|
|
|
|
|
|
|
import {call} from 'core/ajax';
|
|
|
|
import notification from 'core/notification';
|
|
|
|
|
|
|
|
import Vue from './vue/vue';
|
|
|
|
|
|
|
|
import Debugger from './util/debugger';
|
|
|
|
import {load_strings} from './util/string-helper';
|
|
|
|
|
2024-02-18 13:47:08 +01:00
|
|
|
import SRComponents from './studyplan-report-components';
|
|
|
|
Vue.use(SRComponents);
|
2024-02-09 14:48:15 +01:00
|
|
|
import ModalComponents from './modedit-modal';
|
|
|
|
Vue.use(ModalComponents);
|
|
|
|
|
|
|
|
import PortalVue from './portal-vue/portal-vue.esm';
|
|
|
|
Vue.use(PortalVue);
|
|
|
|
import BootstrapVue from './bootstrap-vue/bootstrap-vue';
|
|
|
|
Vue.use(BootstrapVue);
|
|
|
|
|
|
|
|
|
|
|
|
let debug = new Debugger("treestudyplanviewer");
|
|
|
|
|
|
|
|
let strings = load_strings({
|
|
|
|
studyplan: {
|
|
|
|
studyplan_select_placeholder: 'studyplan_select_placeholder',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the Page
|
|
|
|
* @param {Number} studyplanid The id of the studyplan we need to view
|
2024-02-18 13:47:08 +01:00
|
|
|
* @param {Number} pageid The id of the studyplan page we need to view
|
|
|
|
* @param {Number} firstperiod The number of the first period to view
|
|
|
|
* @param {Number} lastperiod The number of the last period to view
|
2024-02-09 14:48:15 +01:00
|
|
|
*/
|
2024-02-18 13:47:08 +01:00
|
|
|
export function init(studyplanid, pageid, firstperiod, lastperiod) {
|
|
|
|
if (undefined === pageid || !Number.isInteger(Number(pageid)) ||
|
|
|
|
undefined === studyplanid || !Number.isInteger(Number(studyplanid))) {
|
|
|
|
debug.error("Did Error: studyplan id and page id not provided as integer numbers to script.",
|
|
|
|
studyplanid, pageid, firstperiod, lastperiod);
|
|
|
|
return; // Do not continue if plan and page are not proper integers
|
|
|
|
}
|
|
|
|
// Ensure a numeric value instead of string.
|
|
|
|
studyplanid = Number(studyplanid);
|
|
|
|
pageid = Number(pageid);
|
2024-02-09 14:48:15 +01:00
|
|
|
|
2024-02-18 13:47:08 +01:00
|
|
|
// Startup app.
|
2024-02-09 14:48:15 +01:00
|
|
|
const app = new Vue({
|
|
|
|
el: '#root',
|
|
|
|
data: {
|
2024-02-18 13:47:08 +01:00
|
|
|
structure: null,
|
2024-02-09 14:48:15 +01:00
|
|
|
},
|
|
|
|
async mounted() {
|
|
|
|
|
2024-02-18 13:47:08 +01:00
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.loadStructure();
|
2024-02-09 14:48:15 +01:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
|
|
|
|
},
|
|
|
|
methods: {
|
2024-02-18 13:47:08 +01:00
|
|
|
loadStructure() {
|
|
|
|
const self = this;
|
|
|
|
this.structure = null; // Starts loading icon. Hides old data.
|
|
|
|
call([{
|
|
|
|
methodname: 'local_treestudyplan_get_report_structure',
|
|
|
|
args: { pageid: pageid}
|
|
|
|
}])[0].then(function(response){
|
|
|
|
self.structure = response;
|
|
|
|
}).catch(notification.exception);
|
|
|
|
}
|
2024-02-09 14:48:15 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|