moodle_local_treestudyplan/amd/build/page-edit-plan.min.js.map
2023-09-09 21:06:11 +02:00

1 line
15 KiB
Plaintext

{"version":3,"file":"page-edit-plan.min.js","sources":["../src/page-edit-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 {get_string,get_strings} from 'core/str';\nimport {call} from 'core/ajax';\nimport notification from 'core/notification';\n\nimport Vue from './vue/vue';\n\n\nimport EditorComponents from './studyplan-editor-components';\nVue.use(EditorComponents);\n\nimport TSComponents from './treestudyplan-components';\nVue.use(TSComponents);\n\nimport ModalComponents from './modedit-modal';\nVue.use(ModalComponents);\nimport Debugger from './util/debugger';\n\nimport {load_strings} from './util/string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\n\nimport PortalVue from './portal-vue/portal-vue.esm';\nVue.use(PortalVue);\nimport BootstrapVue from './bootstrap-vue/bootstrap-vue';\nVue.use(BootstrapVue);\n\nimport {Drag, Drop, DropList} from './vue-easy-dnd/vue-easy-dnd.esm';\nVue.component('drag',Drag);\nVue.component('drop',Drop);\nVue.component('drop-list',DropList);\n\nconst debug = new Debugger(\"treestudyplan\");\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 * @param {object} options Options to be passed to this script\n */\nexport function init(contextid,categoryid,options) {\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 debug.info(\"options\",options);\n if ( options !== null && typeof options === 'object' && !Array.isArray(options) ) {\n if ( !options.defaultAggregation ) {\n options.defaultAggregation = \"core\";\n }\n } else {\n options = { defaultAggregation: \"core\"};\n }\n\n const in_systemcontext = (contextid <= 1);\n\n // Setup the initial Vue app for this page\n let app = new Vue({\n el: '#root',\n data: {\n create: {\n studyplan: {\n name: '',\n shortname: '',\n description: '',\n idnumber: '',\n slots : 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: options.defaultAggregation,\n aggregation_config: '',\n }\n },\n toolbox: {\n shown: false,\n right: true,\n },\n activestudyplan: null,\n loadingstudyplan: false,\n studyplans: [],\n frameworks: [],\n badges: [],\n courses: [],\n text: strings.studyplan,\n usedcontexts: [],\n },\n created() {\n this.$root.$on('studyplanRemoved',(studyplan)=>{\n\n if(app.activestudyplan == studyplan){\n app.activestudyplan = null;\n }\n\n // remove studyplan from index list\n let index = null;\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == studyplan.id){\n index = idx;\n break;\n }\n }\n if(index){\n app.studyplans.splice(index, 1);\n }\n\n });\n },\n mounted() {\n call([{\n methodname: 'local_treestudyplan_list_studyplans',\n args: { context_id: contextid}\n }])[0].done(function(response){\n const timingval = { future: 0, present: 1, past: 2, };\n response.sort((a,b) => {\n const timinga = TSComponents.studyplanTiming(a);\n const timingb = TSComponents.studyplanTiming(b);\n\n let t = timingval[timinga] - timingval[timingb];\n if(t == 0){\n // sort by start date if timing is equal\n t = new Date(b.startdate).getTime() - new Date(a.startdate).getTime();\n\n if (t == 0) {\n // sort by name if timing is equal\n t = a.name.localeCompare(b.name);\n }\n }\n return t;\n });\n app.studyplans = response;\n\n // load studyplan from hash if applicable\n const hash = location.hash.replace('#','');\n if(hash){\n for(let idx in app.studyplans){\n if(app.studyplans[idx].id == hash){\n app.selectStudyplan(app.studyplans[idx]);\n break;\n }\n }\n }\n }).fail(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_badges',\n args: {}\n }])[0].done(function(response){\n app.badges = response;\n }).fail(notification.exception);\n call([{\n methodname: 'local_treestudyplan_map_categories',\n args: {root_id: categoryid}\n }])[0].done(function(response){\n app.courses = response;\n }).fail(notification.exception);\n call([{\n methodname: 'local_treestudyplan_list_used_categories',\n args: { operation: 'edit'}\n }])[0].done(function(response){\n app.usedcontexts = response;\n }).fail(notification.exception);\n\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 filterComponentType(){\n return {\n item: false,\n component: true,\n span: 1,\n type: 'filter',\n };\n },\n },\n methods: {\n closeStudyplan() {\n app.activestudyplan = null;\n window.location.hash = '';\n },\n movedStudyplan(plan,from,to) {\n // reload the page in the new context (needed, since a number of links are not reactive in the page)\n const params = new URLSearchParams(location.search);\n params.delete('categoryid');\n params.set(\"contextid\", to);\n window.location.search = params.toString();\n },\n onStudyPlanCreated(newstudyplan){\n app.studyplans.push(newstudyplan);\n app.selectStudyplan(newstudyplan);\n\n },\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 selectStudyplan(studyplan){\n // fetch studyplan\n app.loadingstudyplan = true;\n app.activestudyplan = 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 debug.info('studyplan processed');\n app.loadingstudyplan = false;\n window.location.hash = app.activestudyplan.id;\n }).fail(function(error){\n notification.exception(error);\n app.loadingstudyplan = false;\n });\n },\n import_studyplan(){\n upload((filename,content)=>{\n call([{\n methodname: 'local_treestudyplan_import_plan',\n args: {\n content: content,\n format: \"application/json\",\n context_id: contextid,\n },\n }])[0].done(function(response){\n if(response.success){\n location.reload();\n } else {\n debug.error(\"Import failed: \",response.msg);\n }\n\n }).fail(notification.exception);\n }, \"application/json\");\n },\n export_plan(plan,format){\n let self = this;\n if(format == undefined || ![\"json\",\"csv\"].includes(format)){\n format = \"json\";\n }\n call([{\n methodname: 'local_treestudyplan_export_plan',\n args: {\n studyplan_id: plan.id,\n format: format\n },\n }])[0].done(function(response){\n\n download(plan.shortname+\".json\",response.content,response.format);\n }).fail(notification.exception);\n },\n toggletoolbox(event) {\n debug.info(event);\n this.toolbox.shown = event;\n }\n },\n });\n}\n\n"],"names":["contextid","categoryid","options","undefined","Number","isInteger","debug","info","_typeof","Array","isArray","defaultAggregation","app","Vue","el","data","create","studyplan","name","shortname","description","idnumber","slots","startdate","enddate","context","aggregation","aggregation_config","toolbox","shown","right","activestudyplan","loadingstudyplan","studyplans","frameworks","badges","courses","text","strings","usedcontexts","created","$root","$on","index","idx","id","splice","mounted","methodname","args","context_id","done","response","timingval","future","present","past","sort","a","b","timinga","TSComponents","studyplanTiming","timingb","t","Date","getTime","localeCompare","hash","location","replace","selectStudyplan","fail","notification","exception","root_id","operation","computed","dropdown_title","this","studyplan_select_placeholder","filterComponentType","item","component","span","type","methods","closeStudyplan","window","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","toString","onStudyPlanCreated","newstudyplan","push","switchContext","ctx","error","import_studyplan","filename","content","format","success","reload","msg","export_plan","includes","studyplan_id","toggletoolbox","event","use","EditorComponents","ModalComponents","PortalVue","BootstrapVue","Drag","Drop","DropList","Debugger"],"mappings":"0+BAqDqBA,WAAUC,WAAWC,SAEiDF,gBAApFG,IAAcH,aAAcI,OAAOC,UAAUD,OAAOJ,cAAeA,WAAY,EAAiB,EAChFI,OAAOJ,YAEnBC,gBADJE,IAAcF,YAAeG,OAAOC,UAAUD,OAAOH,aACpCG,OAAOH,YADyD,EAGpFK,MAAMC,KAAK,UAAUL,SACJ,OAAZA,SAAuC,WAAnBM,QAAON,UAAyBO,MAAMC,QAAQR,SAKnEA,QAAU,CAAES,mBAAoB,QAJ1BT,QAAQS,qBACVT,QAAQ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