moodle_local_treestudyplan/amd/build/page-edit-plan.min.js.map
2023-08-07 17:03:49 +02:00

1 line
14 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';\nimport Vue from './vue';\nimport EditorComponents from './studyplan-editor-components';\nimport TSComponents from './treestudyplan-components';\nimport ModalComponents from './modedit-modal';\nimport Debugger from './debugger';\n\nimport {load_strings} from './string-helper';\nimport {ProcessStudyplan} from './studyplan-processor';\nimport {download,upload} from './downloader';\n\nimport PortalVue from './portal-vue';\nimport BootstrapVue from './bootstrap-vue';\nimport {Drag, Drop, DropList} from './vue-easy-dnd';\nVue.use(PortalVue);\nVue.use(BootstrapVue);\nVue.use(TSComponents);\nVue.use(EditorComponents);\nvue.use(ModalComponents);\nVue.component('drag',Drag);\nVue.component('drop',Drop);\nVue.component('drop-list',DropList);\n\n\nimport vue from './vue';\n\nconst debug = new Debugger(\"treestudyplan\");\ndebug.enable();\n\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(contextid) || contextid < 1 ){ contextid = 1;}\n if(undefined === categoryid || !Number.isInteger(categoryid)){ categoryid = 0;}\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 slots : 4,\n startdate: '2020-08-01',\n enddate: '',\n context: contextid,\n aggregation: 'bistate',\n aggregation_config: '',\n }\n },\n toolbox: {\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: true,\n component: false,\n span: 1,\n type: 'filter',\n };\n },\n },\n methods: {\n closeStudyplan() {\n app.activestudyplan = null;\n 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 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 },\n });\n}\n\n"],"names":["contextid","categoryid","undefined","Number","isInteger","app","Vue","el","data","create","studyplan","name","shortname","description","slots","startdate","enddate","context","aggregation","aggregation_config","toolbox","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","movedStudyplan","plan","from","to","params","URLSearchParams","search","delete","set","window","toString","onStudyPlanCreated","newstudyplan","push","switchContext","ctx","debug","info","error","import_studyplan","filename","content","format","success","reload","msg","export_plan","includes","studyplan_id","use","PortalVue","BootstrapVue","EditorComponents","ModalComponents","Drag","Drop","DropList","Debugger","enable"],"mappings":"oqBAmDqBA,WAAUC,kBAExBC,IAAcF,aAAcG,OAAOC,UAAUJ,aAAcA,WAAY,KAAKA,WAAY,QACxFE,IAAcD,YAAeE,OAAOC,UAAUH,cAAcA,WAAa,OAKxEI,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,OAAQ,CACJC,UAAW,CACPC,KAAM,GACNC,UAAW,GACXC,YAAa,GACbC,MAAQ,EACRC,UAAW,aACXC,QAAS,GACTC,QAASjB,WACTkB,YAAa,UACbC,mBAAoB,KAG5BC,QAAS,CACLC,OAAO,GAEXC,gBAAiB,KACjBC,kBAAkB,EAClBC,WAAY,GACZC,WAAY,GACZC,OAAQ,GACRC,QAAS,GACTC,KAAMC,QAAQnB,UACdoB,aAAc,IAElBC,wBACSC,MAAMC,IAAI,oBAAmB,SAACvB,WAE5BL,IAAIiB,iBAAmBZ,YACtBL,IAAIiB,gBAAkB,UAItBY,MAAQ,SACR,IAAIC,OAAO9B,IAAImB,cACZnB,IAAImB,WAAWW,KAAKC,IAAM1B,UAAU0B,GAAG,CACtCF,MAAQC,UAIbD,OACC7B,IAAImB,WAAWa,OAAOH,MAAO,OAKzCI,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