From c04827d48c48e84ca0cf19799682e3874b187346 Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Thu, 17 Aug 2023 23:29:32 +0200 Subject: [PATCH] Cleanup and bugfix in category only capabilities (non-system) --- amd/build/page-edit-plan.min.js | 2 +- amd/build/page-edit-plan.min.js.map | 2 +- amd/build/page-view-plan.min.js | 2 +- amd/build/page-view-plan.min.js.map | 2 +- amd/src/page-edit-plan.js | 6 +- amd/src/page-view-plan.js | 6 +- css/vue-hsluv-picker.css | 91 ----------------------------- edit-plan.php | 18 ++++-- view-plan.php | 1 - 9 files changed, 26 insertions(+), 104 deletions(-) delete mode 100644 css/vue-hsluv-picker.css diff --git a/amd/build/page-edit-plan.min.js b/amd/build/page-edit-plan.min.js index d9c2b04..84851bc 100644 --- a/amd/build/page-edit-plan.min.js +++ b/amd/build/page-edit-plan.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-edit-plan",["exports","core/str","core/ajax","core/notification","./vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./debugger","./string-helper","./studyplan-processor","./downloader","./portal-vue","./bootstrap-vue","./vue-easy-dnd"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_stringHelper,_studyplanProcessor,_downloader,_portalVue,_bootstrapVue,_vueEasyDnd){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(_contextid,categoryid){(void 0===_contextid||!Number.isInteger(_contextid)||_contextid<1)&&(_contextid=1);void 0!==categoryid&&Number.isInteger(categoryid)||(categoryid=0);var app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",idnumber:"",slots:4,startdate:"2020-08-01",enddate:"",context:_contextid,aggregation:"bistate",aggregation_config:""}},toolbox:{right:!0},activestudyplan:null,loadingstudyplan:!1,studyplans:[],frameworks:[],badges:[],courses:[],text:strings.studyplan,usedcontexts:[]},created:function(){this.$root.$on("studyplanRemoved",(function(studyplan){app.activestudyplan==studyplan&&(app.activestudyplan=null);var index=null;for(var idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted:function(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:_contextid}}])[0].done((function(response){var timingval={future:0,present:1,past:2};response.sort((function(a,b){var timinga=_treestudyplanComponents.default.studyplanTiming(a),timingb=_treestudyplanComponents.default.studyplanTiming(b),t=timingval[timinga]-timingval[timingb];return 0==t&&0==(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime())&&(t=a.name.localeCompare(b.name)),t})),app.studyplans=response;var hash=location.hash.replace("#","");if(hash)for(var idx in app.studyplans)if(app.studyplans[idx].id==hash){app.selectStudyplan(app.studyplans[idx]);break}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_badges",args:{}}])[0].done((function(response){app.badges=response})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_map_categories",args:{root_id:categoryid}}])[0].done((function(response){app.courses=response})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"edit"}}])[0].done((function(response){app.usedcontexts=response})).fail(_notification.default.exception)},computed:{dropdown_title:function(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:function(){return _contextid},filterComponentType:function(){return{item:!1,component:!0,span:1,type:"filter"}}},methods:{closeStudyplan:function(){app.activestudyplan=null,location.hash=""},movedStudyplan:function(plan,from,to){var params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),window.location.search=params.toString()},onStudyPlanCreated:function(newstudyplan){app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan)},switchContext:function(ctx){var params=new URLSearchParams(location.search);params.set("categoryid",ctx.id),window.location.search=params.toString()},selectStudyplan:function(studyplan){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),debug.info("studyplan processed"),app.loadingstudyplan=!1,location.hash=app.activestudyplan.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},import_studyplan:function(){(0,_downloader.upload)((function(filename,content){(0,_ajax.call)([{methodname:"local_treestudyplan_import_plan",args:{content:content,format:"application/json",context_id:_contextid}}])[0].done((function(response){response.success?location.reload():debug.error("Import failed: ",response.msg)})).fail(_notification.default.exception)}),"application/json")},export_plan:function(plan,format){null!=format&&["json","csv"].includes(format)||(format="json"),(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:plan.id,format:format}}])[0].done((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).fail(_notification.default.exception)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_modeditModal.default),_vue.default.component("drag",_vueEasyDnd.Drag),_vue.default.component("drop",_vueEasyDnd.Drop),_vue.default.component("drop-list",_vueEasyDnd.DropList);var debug=new _debugger.default("treestudyplan");debug.enable();var strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); +define("local_treestudyplan/page-edit-plan",["exports","core/str","core/ajax","core/notification","./vue","./studyplan-editor-components","./treestudyplan-components","./modedit-modal","./debugger","./string-helper","./studyplan-processor","./downloader","./portal-vue","./bootstrap-vue","./vue-easy-dnd"],(function(_exports,_str,_ajax,_notification,_vue,_studyplanEditorComponents,_treestudyplanComponents,_modeditModal,_debugger,_stringHelper,_studyplanProcessor,_downloader,_portalVue,_bootstrapVue,_vueEasyDnd){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=function(_contextid,categoryid){_contextid=void 0===_contextid||!Number.isInteger(Number(_contextid))||_contextid<1?1:Number(_contextid);categoryid=void 0!==categoryid&&Number.isInteger(Number(categoryid))?Number(categoryid):0;var app=new _vue.default({el:"#root",data:{create:{studyplan:{name:"",shortname:"",description:"",idnumber:"",slots:4,startdate:"2020-08-01",enddate:"",context:_contextid,aggregation:"bistate",aggregation_config:""}},toolbox:{right:!0},activestudyplan:null,loadingstudyplan:!1,studyplans:[],frameworks:[],badges:[],courses:[],text:strings.studyplan,usedcontexts:[]},created:function(){this.$root.$on("studyplanRemoved",(function(studyplan){app.activestudyplan==studyplan&&(app.activestudyplan=null);var index=null;for(var idx in app.studyplans)if(app.studyplans[idx].id==studyplan.id){index=idx;break}index&&app.studyplans.splice(index,1)}))},mounted:function(){(0,_ajax.call)([{methodname:"local_treestudyplan_list_studyplans",args:{context_id:_contextid}}])[0].done((function(response){var timingval={future:0,present:1,past:2};response.sort((function(a,b){var timinga=_treestudyplanComponents.default.studyplanTiming(a),timingb=_treestudyplanComponents.default.studyplanTiming(b),t=timingval[timinga]-timingval[timingb];return 0==t&&0==(t=new Date(b.startdate).getTime()-new Date(a.startdate).getTime())&&(t=a.name.localeCompare(b.name)),t})),app.studyplans=response;var hash=location.hash.replace("#","");if(hash)for(var idx in app.studyplans)if(app.studyplans[idx].id==hash){app.selectStudyplan(app.studyplans[idx]);break}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_badges",args:{}}])[0].done((function(response){app.badges=response})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_map_categories",args:{root_id:categoryid}}])[0].done((function(response){app.courses=response})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"edit"}}])[0].done((function(response){app.usedcontexts=response})).fail(_notification.default.exception)},computed:{dropdown_title:function(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:function(){return _contextid},filterComponentType:function(){return{item:!1,component:!0,span:1,type:"filter"}}},methods:{closeStudyplan:function(){app.activestudyplan=null,location.hash=""},movedStudyplan:function(plan,from,to){var params=new URLSearchParams(location.search);params.delete("categoryid"),params.set("contextid",to),window.location.search=params.toString()},onStudyPlanCreated:function(newstudyplan){app.studyplans.push(newstudyplan),app.selectStudyplan(newstudyplan)},switchContext:function(ctx){var params=new URLSearchParams(location.search);params.set("categoryid",ctx.id),window.location.search=params.toString()},selectStudyplan:function(studyplan){app.loadingstudyplan=!0,app.activestudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),debug.info("studyplan processed"),app.loadingstudyplan=!1,location.hash=app.activestudyplan.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},import_studyplan:function(){(0,_downloader.upload)((function(filename,content){(0,_ajax.call)([{methodname:"local_treestudyplan_import_plan",args:{content:content,format:"application/json",context_id:_contextid}}])[0].done((function(response){response.success?location.reload():debug.error("Import failed: ",response.msg)})).fail(_notification.default.exception)}),"application/json")},export_plan:function(plan,format){null!=format&&["json","csv"].includes(format)||(format="json"),(0,_ajax.call)([{methodname:"local_treestudyplan_export_plan",args:{studyplan_id:plan.id,format:format}}])[0].done((function(response){(0,_downloader.download)(plan.shortname+".json",response.content,response.format)})).fail(_notification.default.exception)}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_studyplanEditorComponents=_interopRequireDefault(_studyplanEditorComponents),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_modeditModal=_interopRequireDefault(_modeditModal),_debugger=_interopRequireDefault(_debugger),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_studyplanEditorComponents.default),_vue.default.use(_modeditModal.default),_vue.default.component("drag",_vueEasyDnd.Drag),_vue.default.component("drop",_vueEasyDnd.Drop),_vue.default.component("drop-list",_vueEasyDnd.DropList);var debug=new _debugger.default("treestudyplan");debug.enable();var strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); //# sourceMappingURL=page-edit-plan.min.js.map \ No newline at end of file diff --git a/amd/build/page-edit-plan.min.js.map b/amd/build/page-edit-plan.min.js.map index 944b1fa..fcfe629 100644 --- a/amd/build/page-edit-plan.min.js.map +++ b/amd/build/page-edit-plan.min.js.map @@ -1 +1 @@ -{"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 idnumber: '',\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: false,\n component: true,\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","idnumber","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,CAC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kB,gBAAgBc,MACrC2B,MAAK,SAASkC,6BACAhC,UAAUgC,OACvB7F,IAAImB,kBAAmB,MAG/B2E,oDACW,SAACC,SAASC,wBACR,CAAC,CACF7D,WAAY,kCACZC,KAAM,CACF4D,QAASA,QACTC,OAAQ,mBACR5D,WAAY1C,eAEhB,GAAG2C,MAAK,SAASC,UACdA,SAAS2D,QACR1C,SAAS2C,SAETR,MAAME,MAAM,kBAAkBtD,SAAS6D,QAG5CzC,KAAKC,sBAAaC,aACtB,qBAEPwC,qBAAYzB,KAAKqB,QAEApG,MAAVoG,QAAwB,CAAC,OAAO,OAAOK,SAASL,UAC/CA,OAAS,uBAER,CAAC,CACE9D,WAAY,kCACZC,KAAM,CACFmE,aAAc3B,KAAK5C,GACnBiE,OAAQA,WAEZ,GAAG3D,MAAK,SAASC,mCAERqC,KAAKrE,UAAU,QAAQgC,SAASyD,QAAQzD,SAAS0D,WAC3DtC,KAAKC,sBAAaC,6cA1OrC2C,IAAIC,iCACJD,IAAIE,oCACJF,IAAIxD,+CACJwD,IAAIG,iDACJH,IAAII,oCACJtC,UAAU,OAAOuC,+BACjBvC,UAAU,OAAOwC,+BACjBxC,UAAU,YAAYyC,0BAKpBpB,MAAQ,IAAIqB,kBAAS,iBAC3BrB,MAAMsB,aAGFxF,SAAU,8BAAa,CACvBpB,UAAW,CACP8D,6BAA8B"} \ No newline at end of file +{"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(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 // 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: '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: false,\n component: true,\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","idnumber","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,YAE4DD,gBAApFE,IAAcF,aAAcG,OAAOC,UAAUD,OAAOH,cAAeA,WAAY,EAAiB,EAChFG,OAAOH,YAEnBC,gBADJC,IAAcD,YAAeE,OAAOC,UAAUD,OAAOF,aACpCE,OAAOF,YADyD,MAMhFI,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,OAAQ,CACJC,UAAW,CACPC,KAAM,GACNC,UAAW,GACXC,YAAa,GACbC,SAAU,GACVC,MAAQ,EACRC,UAAW,aACXC,QAAS,GACTC,QAASlB,WACTmB,YAAa,UACbC,mBAAoB,KAG5BC,QAAS,CACLC,OAAO,GAEXC,gBAAiB,KACjBC,kBAAkB,EAClBC,WAAY,GACZC,WAAY,GACZC,OAAQ,GACRC,QAAS,GACTC,KAAMC,QAAQpB,UACdqB,aAAc,IAElBC,wBACSC,MAAMC,IAAI,oBAAmB,SAACxB,WAE5BL,IAAIkB,iBAAmBb,YACtBL,IAAIkB,gBAAkB,UAItBY,MAAQ,SACR,IAAIC,OAAO/B,IAAIoB,cACZpB,IAAIoB,WAAWW,KAAKC,IAAM3B,UAAU2B,GAAG,CACtCF,MAAQC,UAIbD,OACC9B,IAAIoB,WAAWa,OAAOH,MAAO,OAKzCI,kCACS,CAAC,CACFC,WAAY,sCACZC,KAAM,CAAEC,WAAY1C,eACpB,GAAG2C,MAAK,SAASC,cACXC,UAAY,CAAEC,OAAQ,EAAGC,QAAS,EAAGC,KAAM,GACjDJ,SAASK,MAAK,SAACC,EAAEC,OACPC,QAAUC,iCAAaC,gBAAgBJ,GACvCK,QAAUF,iCAAaC,gBAAgBH,GAEzCK,EAAIX,UAAUO,SAAWP,UAAUU,gBAC/B,GAALC,GAIU,IAFTA,EA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newline at end of file diff --git a/amd/build/page-view-plan.min.js b/amd/build/page-view-plan.min.js index 822e4fd..cbb6dc8 100644 --- a/amd/build/page-view-plan.min.js +++ b/amd/build/page-view-plan.min.js @@ -1,3 +1,3 @@ -define("local_treestudyplan/page-view-plan",["exports","core/ajax","core/notification","./vue","./debugger","./string-helper","./studyplan-processor","./treestudyplan-components","./report-viewer-components","./modedit-modal","./portal-vue","./bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_treestudyplanComponents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i0)for(var idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1]);break}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"view"}}])[0].done((function(response){var contexts=[];for(var ix in response)response[ix].studyplancount>0&&contexts.push(response[ix]);app.usedcontexts=contexts})).fail(_notification.default.exception);case 2:case"end":return _context.stop()}}),_callee)})),function(){var self=this,args=arguments;return new Promise((function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(void 0)}))})();var fn},computed:{dropdown_title:function(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:function(){return _contextid}},methods:{switchContext:function(ctx){var params=new URLSearchParams(location.search);params.set("categoryid",ctx.id),window.location.search=params.toString()},closeStudyplan:function(){app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null},selectStudyplan:function(studyplan,studentid){app.loadingstudyplan=!0,app.activestudyplan=null,app.associatedstudents=[],app.selectedstudent=null,app.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),app.displayedstudyplan=app.activestudyplan,app.loadingstudyplan=!1,location.hash=app.activestudyplan.id,(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated",args:{studyplan_id:studyplan.id}}])[0].done((function(response){if(app.associatedstudents=response,studentid){var _step,_iterator=function(o,allowArrayLike){var it="undefined"!=typeof Symbol&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(o))||allowArrayLike&&o&&"number"==typeof o.length){it&&(o=it);var i=0,F=function(){};return{s:F,n:function(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var err,normalCompletion=!0,didErr=!1;return{s:function(){it=it.call(o)},n:function(){var step=it.next();return normalCompletion=step.done,step},e:function(_e2){didErr=!0,err=_e2},f:function(){try{normalCompletion||null==it.return||it.return()}finally{if(didErr)throw err}}}}(app.associatedstudents);try{for(_iterator.s();!(_step=_iterator.n()).done;){var student=_step.value;if(student.id==studentid){app.showStudentView(student);break}}}catch(err){_iterator.e(err)}finally{_iterator.f()}}})).fail(_notification.default.exception)})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView:function(student){app.selectedstudent=student,app.studentstudyplan=null,app.loadingstudyplan=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_get_user_studyplan",args:{userid:student.id,studyplanid:app.activestudyplan.id}}])[0].done((function(response){app.studentstudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,location.hash=app.activestudyplan.id+"-"+student.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showOverview:function(){app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default),new _debugger.default("treestudyplanviewer").enable();var strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); +define("local_treestudyplan/page-view-plan",["exports","core/ajax","core/notification","./vue","./debugger","./string-helper","./studyplan-processor","./treestudyplan-components","./report-viewer-components","./modedit-modal","./portal-vue","./bootstrap-vue"],(function(_exports,_ajax,_notification,_vue,_debugger,_stringHelper,_studyplanProcessor,_treestudyplanComponents,_reportViewerComponents,_modeditModal,_portalVue,_bootstrapVue){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i0)for(var idx in app.studyplans)if(app.studyplans[idx].id==parts[0]){app.selectStudyplan(app.studyplans[idx],parts[1]);break}})).fail(_notification.default.exception),(0,_ajax.call)([{methodname:"local_treestudyplan_list_used_categories",args:{operation:"view"}}])[0].done((function(response){var contexts=[];for(var ix in response)response[ix].studyplancount>0&&contexts.push(response[ix]);app.usedcontexts=contexts})).fail(_notification.default.exception);case 2:case"end":return _context.stop()}}),_callee)})),function(){var self=this,args=arguments;return new Promise((function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(void 0)}))})();var fn},computed:{dropdown_title:function(){return this.activestudyplan&&this.activestudyplan.name?this.activestudyplan.name:this.text.studyplan_select_placeholder},contextid:function(){return _contextid}},methods:{switchContext:function(ctx){var params=new URLSearchParams(location.search);params.set("categoryid",ctx.id),window.location.search=params.toString()},closeStudyplan:function(){app.activestudyplan=null,app.associatedstudents=[],app.studentstudyplan=[],app.displayedstudyplan=null},selectStudyplan:function(studyplan,studentid){app.loadingstudyplan=!0,app.activestudyplan=null,app.associatedstudents=[],app.selectedstudent=null,app.studentstudyplan=null,(0,_ajax.call)([{methodname:"local_treestudyplan_get_studyplan_map",args:{id:studyplan.id}}])[0].done((function(response){app.activestudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!0),app.displayedstudyplan=app.activestudyplan,app.loadingstudyplan=!1,location.hash=app.activestudyplan.id,(0,_ajax.call)([{methodname:"local_treestudyplan_all_associated",args:{studyplan_id:studyplan.id}}])[0].done((function(response){if(app.associatedstudents=response,studentid){var _step,_iterator=function(o,allowArrayLike){var it="undefined"!=typeof Symbol&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(o))||allowArrayLike&&o&&"number"==typeof o.length){it&&(o=it);var i=0,F=function(){};return{s:F,n:function(){return i>=o.length?{done:!0}:{done:!1,value:o[i++]}},e:function(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var err,normalCompletion=!0,didErr=!1;return{s:function(){it=it.call(o)},n:function(){var step=it.next();return normalCompletion=step.done,step},e:function(_e2){didErr=!0,err=_e2},f:function(){try{normalCompletion||null==it.return||it.return()}finally{if(didErr)throw err}}}}(app.associatedstudents);try{for(_iterator.s();!(_step=_iterator.n()).done;){var student=_step.value;if(student.id==studentid){app.showStudentView(student);break}}}catch(err){_iterator.e(err)}finally{_iterator.f()}}})).fail(_notification.default.exception)})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showStudentView:function(student){app.selectedstudent=student,app.studentstudyplan=null,app.loadingstudyplan=!0,(0,_ajax.call)([{methodname:"local_treestudyplan_get_user_studyplan",args:{userid:student.id,studyplanid:app.activestudyplan.id}}])[0].done((function(response){app.studentstudyplan=(0,_studyplanProcessor.ProcessStudyplan)(response,!1),app.displayedstudyplan=app.studentstudyplan,app.loadingstudyplan=!1,location.hash=app.activestudyplan.id+"-"+student.id})).fail((function(error){_notification.default.exception(error),app.loadingstudyplan=!1}))},showOverview:function(){app.selectedstudent=null,app.studentstudyplan=null,app.displayedstudyplan=app.activestudyplan}}})},_notification=_interopRequireDefault(_notification),_vue=_interopRequireDefault(_vue),_debugger=_interopRequireDefault(_debugger),_treestudyplanComponents=_interopRequireDefault(_treestudyplanComponents),_reportViewerComponents=_interopRequireDefault(_reportViewerComponents),_modeditModal=_interopRequireDefault(_modeditModal),_portalVue=_interopRequireDefault(_portalVue),_bootstrapVue=_interopRequireDefault(_bootstrapVue),_vue.default.use(_treestudyplanComponents.default),_vue.default.use(_reportViewerComponents.default),_vue.default.use(_modeditModal.default),_vue.default.use(_portalVue.default),_vue.default.use(_bootstrapVue.default),new _debugger.default("treestudyplanviewer").enable();var strings=(0,_stringHelper.load_strings)({studyplan:{studyplan_select_placeholder:"studyplan_select_placeholder"}})})); //# sourceMappingURL=page-view-plan.min.js.map \ No newline at end of file diff --git a/amd/build/page-view-plan.min.js.map b/amd/build/page-view-plan.min.js.map index b349a17..cefee19 100644 --- a/amd/build/page-view-plan.min.js.map +++ b/amd/build/page-view-plan.min.js.map @@ -1 +1 @@ -{"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';\nimport Vue from './vue';\n\nimport Debugger from './debugger';\nimport {load_strings} from './string-helper';\nimport {ProcessStudyplan} 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 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 mounted() {\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","app","Vue","el","data","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","studyplan","toolbox","right","usedcontexts","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","window","toString","closeStudyplan","studentid","studyplan_id","student","showStudentView","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","enable"],"mappings":"w8BA4CsBA,WAAUC,kBAEzBC,IAAcF,aAAcG,OAAOC,UAAUJ,aAAcA,WAAY,KAAKA,WAAY,QACxFE,IAAcD,YAAeE,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AASC,KAAOvC,IAAIK,gBAAgBuC,GAAK,IAAM0B,QAAQ1B,MACxDE,MAAK,SAAS0B,6BACAxB,UAAUwB,OACvBxE,IAAIS,kBAAmB,MAK/BkE,wBACI3E,IAAIO,gBAAkB,KACtBP,IAAIQ,iBAAmB,KACvBR,IAAII,mBAAqBJ,IAAIK,4cApLzCuE,IAAI7C,+CAGJ6C,IAAIC,8CAEJD,IAAIE,oCAGJF,IAAIG,iCAEJH,IAAII,uBAGI,IAAIC,kBAAS,uBACnBC,aAEFtE,SAAU,8BAAa,CACvBC,UAAW,CACP4C,6BAA8B"} \ No newline at end of file +{"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';\nimport Vue from './vue';\n\nimport Debugger from './debugger';\nimport {load_strings} from './string-helper';\nimport {ProcessStudyplan} 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(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 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].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","app","Vue","el","data","displayedstudyplan","activestudyplan","associatedstudents","selectedstudent","studentstudyplan","loadingstudyplan","studyplans","text","strings","studyplan","toolbox","right","usedcontexts","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","window","toString","closeStudyplan","studentid","studyplan_id","student","showStudentView","error","userid","studyplanid","showOverview","use","RVComponents","ModalComponents","PortalVue","BootstrapVue","Debugger","enable"],"mappings":"w8BA4CsBA,WAAUC,YAE2DD,gBAApFE,IAAcF,aAAcG,OAAOC,UAAUD,OAAOH,cAAeA,WAAY,EAAiB,EAChFG,OAAOH,YAEnBC,gBADJC,IAAcD,YAAeE,OAAOC,UAAUD,OAAOF,aACpCE,OAAOF,YADyD,MAKhFI,IAAM,IAAIC,aAAI,CACdC,GAAI,QACJC,KAAM,CACFC,mBAAoB,KACpBC,gBAAiB,KACjBC,mBAAoB,GACpBC,gBAAiB,KACjBC,iBAAkB,KAClBC,kBAAkB,EAClBC,WAAY,GACZC,KAAMC,QAAQC,UACdC,QAAS,CACLC,OAAO,GAEXC,aAAc,IAEZC,6LACG,CAAC,CACFC,WAAY,sCACZC,KAAM,CAACC,WAAYzB,eACnB,GAAG0B,MAAK,SAASC,cACXC,UAAY,CAAEC,QAAS,EAAGC,KAAM,EAAGC,OAAQ,GACjDJ,SAASK,MAAK,SAACC,EAAEC,OACPC,QAAUC,iCAAaC,gBAAgBJ,GACvCK,QAAUF,iCAAaC,gBAAgBH,GAEvCK,EAAIX,UAAUO,SAAWP,UAAUU,gBACjC,GAALC,EAEQN,EAAEO,KAAKC,cAAcP,EAAEM,MAGvBD,KAGflC,IAAIU,WAAaY,aAGXe,MADOC,SAASC,KAAKC,QAAQ,IAAI,IACpBC,MAAM,QAEpBJ,OAASA,MAAMK,OAAS,MACrB,IAAIC,OAAO3C,IAAIU,cACZV,IAAIU,WAAWiC,KAAKC,IAAMP,MAAM,GAAG,CAClCrC,IAAI6C,gBAAgB7C,IAAIU,WAAWiC,KAAKN,MAAM,cAK3DS,KAAKC,sBAAaC,0BAChB,CAAC,CACF9B,WAAY,2CACZC,KAAM,CAAE8B,UAAW,WACnB,GAAG5B,MAA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B8D,yBAAgBD,SACZtE,IAAIO,gBAAkB+D,QACtBtE,IAAIQ,iBAAmB,KACvBR,IAAIS,kBAAmB,iBAClB,CAAC,CACFS,WAAY,yCACZC,KAAM,CAAEsD,OAAQH,QAAQ1B,GAAI8B,YAAa1E,IAAIK,gBAAgBuC,OAC7D,GAAGvB,MAAK,SAASC,UACjBtB,IAAIQ,kBAAmB,wCAAiBc,UAAS,GACjDtB,IAAII,mBAAqBJ,IAAIQ,iBAC7BR,IAAIS,kBAAmB,EACvB6B,SAASC,KAAOvC,IAAIK,gBAAgBuC,GAAK,IAAM0B,QAAQ1B,MACxDE,MAAK,SAAS0B,6BACAxB,UAAUwB,OACvBxE,IAAIS,kBAAmB,MAK/BkE,wBACI3E,IAAIO,gBAAkB,KACtBP,IAAIQ,iBAAmB,KACvBR,IAAII,mBAAqBJ,IAAIK,4cAtLzCuE,IAAI7C,+CAGJ6C,IAAIC,8CAEJD,IAAIE,oCAGJF,IAAIG,iCAEJH,IAAII,uBAGI,IAAIC,kBAAS,uBACnBC,aAEFtE,SAAU,8BAAa,CACvBC,UAAW,CACP4C,6BAA8B"} \ No newline at end of file diff --git a/amd/src/page-edit-plan.js b/amd/src/page-edit-plan.js index a1a1633..e94abd5 100644 --- a/amd/src/page-edit-plan.js +++ b/amd/src/page-edit-plan.js @@ -51,8 +51,10 @@ let strings = load_strings({ */ export function init(contextid,categoryid) { // Make sure the id's are numeric and integer - if(undefined === contextid || !Number.isInteger(contextid) || contextid < 1 ){ contextid = 1;} - if(undefined === categoryid || !Number.isInteger(categoryid)){ categoryid = 0;} + if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;} + else { contextid = Number(contextid);} // ensure a numeric value instead of string + if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;} + else { categoryid = Number(categoryid);} // ensure a numeric value instead of string const in_systemcontext = (contextid <= 1); diff --git a/amd/src/page-view-plan.js b/amd/src/page-view-plan.js index ade5c7e..6332164 100644 --- a/amd/src/page-view-plan.js +++ b/amd/src/page-view-plan.js @@ -44,8 +44,10 @@ let strings = load_strings({ */ export function init(contextid,categoryid) { // Make sure the id's are numeric and integer - if(undefined === contextid || !Number.isInteger(contextid) || contextid < 1 ){ contextid = 1;} - if(undefined === categoryid || !Number.isInteger(categoryid)){ categoryid = 0;} + if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;} + else { contextid = Number(contextid);} // ensure a numeric value instead of string + if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;} + else { categoryid = Number(categoryid);} // ensure a numeric value instead of string const in_systemcontext = (contextid <= 1); diff --git a/css/vue-hsluv-picker.css b/css/vue-hsluv-picker.css deleted file mode 100644 index a0808ff..0000000 --- a/css/vue-hsluv-picker.css +++ /dev/null @@ -1,91 +0,0 @@ -.vue-hsluv-picker { - min-width: 300px; - display: flex; - flex-direction: column; -} - -.vue-hsluv-picker.horizontal { - flex-direction: row; -} - -.vue-hsluv-picker.horizontal .display { - margin-top: 10px; -} - -.vue-hsluv-picker td.cell-input { - width: 90px; - padding-right: 20px; -} - -.vue-hsluv-picker td.cell-input input { - margin: 0; - height: 22px; - background: transparent; - outline: none; - border: 1px solid #333; - border-radius: 0; - text-align: right; - width: 100%; - padding: 0; -} - -.vue-hsluv-picker td.cell-input.cell-input-hex input { - font-family: monospace; - border-color: #555; -} - -.vue-hsluv-picker table { - margin-top: 20px; - width: 100%; -} - -.vue-hsluv-picker table td { - padding: 5px 5px; - vertical-align: top; - border: none; -} - -.vue-hsluv-picker table td.picker-label { - color: #eee; - width: 30px; - line-height: 22px; -} - -.vue-hsluv-picker table .swatch { - height: 50px; - border-color: #555; - border-style: solid; - border-width: 1px; -} - -.vue-hsluv-picker .explanation-text { - margin-bottom: 60px; - margin-top: 100px; -} - -.vue-hsluv-picker .range-slider { - height: 22px; - display: block; - position: relative; - border-color: #555; - border-style: solid; - border-width: 1px; -} - -.vue-hsluv-picker .range-slider-handle { - display: inline-block; - position: absolute; - width: 6px; - left: -5px; - top: -2px; - height: calc(100% + 4px); - cursor: default; - border: 2px solid #333; - touch-action: pan-y; - -ms-touch-action: pan-y; - background-color: #fff; -} - -.vue-hsluv-picker circle.outercircle { - stroke: black; -} diff --git a/edit-plan.php b/edit-plan.php index bec04c0..e28817c 100644 --- a/edit-plan.php +++ b/edit-plan.php @@ -31,8 +31,19 @@ elseif($contextid > 0) } else { - $categoryid = 0; - $studyplancontext = $systemcontext; + // If no context is selected, find the first available one + $available_contexts = courseservice::list_accessible_categories_with_usage("edit"); + $contextid=1; // fallback to system context + foreach($available_contexts as $ctx){ + if($ctx->count > 0){ + $contextid = $ctx->ctxid; + break; + } + } + // reload page with selected category + $url = new \moodle_url('/local/treestudyplan/edit-plan.php',["contextid" => $contextid]); + header('Location: '.$url->out(false), true, 302); + exit; } require_capability('local/treestudyplan:editstudyplan',$studyplancontext); @@ -52,7 +63,6 @@ if($studyplancontext->id > 1){ // Load javascripts and specific css $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/bootstrap-vue.min.css')); $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css')); -$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/vue-hsluv-picker.css')); $PAGE->requires->js_call_amd('local_treestudyplan/page-edit-plan', 'init', [$studyplancontext->id,$categoryid]); @@ -122,7 +132,7 @@ print $OUTPUT->header(); diff --git a/view-plan.php b/view-plan.php index 6a3d8b0..8e18ecc 100644 --- a/view-plan.php +++ b/view-plan.php @@ -62,7 +62,6 @@ if($studyplancontext->id > 1){ // Load javascripts and specific css $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/bootstrap-vue.min.css')); $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css')); -$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/vue-hsluv-picker.css')); $PAGE->requires->js_call_amd('local_treestudyplan/page-view-plan', 'init',[$studyplancontext->id,$categoryid]); //Local translate function