From 235972e2f4a55f49bff74ec1834453786bd4fd34 Mon Sep 17 00:00:00 2001 From: PMKuipers Date: Fri, 4 Aug 2023 11:54:16 +0200 Subject: [PATCH] Multi-period courses drag and drop --- amd/src/page-edit-plan.js | 11 +- amd/src/studyplan-editor-components.js | 277 ++++++++++++------------- amd/src/treestudyplan-components.js | 2 +- classes/studyitem.php | 4 + css/devstyles.css | 4 +- edit-plan.php | 8 +- 6 files changed, 151 insertions(+), 155 deletions(-) diff --git a/amd/src/page-edit-plan.js b/amd/src/page-edit-plan.js index b695d58..bebf492 100644 --- a/amd/src/page-edit-plan.js +++ b/amd/src/page-edit-plan.js @@ -171,7 +171,15 @@ export function init(contextid,categoryid) { }, contextid(){ return contextid; - } + }, + filterComponentType(){ + return { + item: true, + component: false, + span: 1, + type: 'filter', + }; + }, }, methods: { closeStudyplan() { @@ -250,7 +258,6 @@ export function init(contextid,categoryid) { download(plan.shortname+".json",response.content,response.format); }).fail(notification.exception); }, - }, }); } diff --git a/amd/src/studyplan-editor-components.js b/amd/src/studyplan-editor-components.js index e4ed47b..3e52601 100644 --- a/amd/src/studyplan-editor-components.js +++ b/amd/src/studyplan-editor-components.js @@ -169,7 +169,6 @@ export default { day: 'day$core', rememberchoice: 'course_timing_rememberchoice', hidewarning: 'course_timing_hidewarning,' - }, studyplan_associate: { associations: 'associations', @@ -1285,7 +1284,7 @@ export default { methods: { countLineLayers(line){ let maxLayer = -1; - for(let i = 0; i <= this.value.slots; i++){ + for(let i = 0; i <= this.page.periods; i++){ const slot = line.slots[i]; // Determine the amount of used layers in a studyline slit for(const ix in line.slots[i].competencies){ @@ -1447,6 +1446,34 @@ export default { }).fail(notification.exception); }, + showslot(line,index, layeridx, type){ + // check if the slot should be hidden because a previous slot has an item with a span + // so big that it hides this slot + const forGradable = (type == 'gradable')?true:false; + const periods = this.page.periods; + let show = true; + for(let i = 0; i < periods; i++){ + if(line.slots[index-i] && line.slots[index-i].competencies){ + const list = line.slots[index-i].competencies; + for(const ix in list){ // Really wish that for ( .. of .. ) would work with the minifier + const item = list[ix]; + if(item.layer == layeridx){ + if(forGradable){ + if(i > 0 && (item.span - i) > 0){ + show = false; + } + } else { + if((item.span - i) > 1){ + show = false; + } + } + } + } + } + } + + return show; + } } , template: @@ -1540,35 +1567,36 @@ export default {