Untangled study line editing from moodle editmode

This commit is contained in:
PMKuipers 2024-02-09 11:15:05 +01:00
parent 32a09a7c44
commit e42323a2e4
11 changed files with 27 additions and 22 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -66,11 +66,9 @@ export function init(contextid,categoryid,options) {
if ( !options.defaultAggregation ) { if ( !options.defaultAggregation ) {
options.defaultAggregation = "core"; options.defaultAggregation = "core";
} }
if ( !options.editMode ) {
options.editMode = false;
}
} else { } else {
options = { defaultAggregation: "core", editMode: false}; options = { defaultAggregation: "core"};
} }
// Setup the initial Vue app for this page // Setup the initial Vue app for this page
@ -109,7 +107,6 @@ export function init(contextid,categoryid,options) {
courses: [], courses: [],
text: strings.studyplan, text: strings.studyplan,
usedcontexts: [], usedcontexts: [],
initialEditMode: !!options.editMode,
}, },
created() { created() {
this.$root.$on('studyplanRemoved',(studyplan)=>{ this.$root.$on('studyplanRemoved',(studyplan)=>{

View File

@ -1198,7 +1198,7 @@ export default {
* T-STUDYPLAN * T-STUDYPLAN
*/ */
Vue.component('t-studyplan', { Vue.component('t-studyplan', {
props: [ 'value', 'index', 'initeditmode'], props: [ 'value', 'index'],
data() { data() {
return { return {
config: { config: {
@ -1274,17 +1274,15 @@ export default {
const self = this; const self = this;
// Listener for the signal that a new connection was made and needs to be drawn // Listener for the signal that a new connection was made and needs to be drawn
// Sent by the incoming item - By convention, outgoing items are responsible for drawing the lines // Sent by the incoming item - By convention, outgoing items are responsible for drawing the lines
ItemEventBus.$on('editModeSet', this.onMoodleEditModeChanged);
ItemEventBus.$on('coursechange', () => { ItemEventBus.$on('coursechange', () => {
self.$emit('pagechanged',this.selectedpage); self.$emit('pagechanged',this.selectedpage);
}); });
}, },
mounted() { mounted() {
/*if(this.value.pages[0].studylines.length == 0){ if(this.value.pages[0].studylines.length == 0){
// start in editmode if studylines on first page are empty // start in editmode if studylines on first page are empty
this.edit.studyline.editmode = true; this.edit.studyline.editmode = true;
}*/ }
this.edit.studyline.editmode = this.initeditmode;
this.$root.$emit('redrawLines'); this.$root.$emit('redrawLines');
this.$emit('pagechanged',this.selectedpage); this.$emit('pagechanged',this.selectedpage);
}, },
@ -1298,9 +1296,6 @@ export default {
} }
}, },
methods: { methods: {
onMoodleEditModeChanged(mode){
this.edit.studyline.editmode = mode;
},
columns(page) { columns(page) {
return 1+ (page.periods * 2); return 1+ (page.periods * 2);
}, },

View File

@ -32,6 +32,11 @@
color: gold; color: gold;
} }
/* Hide the edit button on studyplan pages */
body.path-local-treestudyplan .editmode-switch-form > * {
visibility: hidden;
}
/******************* /*******************
* *
* Invite manager * Invite manager

View File

@ -80,7 +80,7 @@ if ($studyplancontext->id > 1) {
if (!$cat->is_uservisible()) { if (!$cat->is_uservisible()) {
throw new \moodle_exception("error:cannotviewcategory","local_treestudyplan","/local/treestudyplan/edit_plan.php",$contextname,print_r($cat,true)); throw new \moodle_exception("error:cannotviewcategory","local_treestudyplan","/local/treestudyplan/edit_plan.php",$contextname);
} }
if (!has_capability('local/treestudyplan:editstudyplan', $studyplancontext)) { if (!has_capability('local/treestudyplan:editstudyplan', $studyplancontext)) {
@ -94,7 +94,6 @@ if ($CFG->debugdeveloper) {
} }
$PAGE->requires->js_call_amd('local_treestudyplan/page-edit-plan', 'init', [$studyplancontext->id, $categoryid, [ $PAGE->requires->js_call_amd('local_treestudyplan/page-edit-plan', 'init', [$studyplancontext->id, $categoryid, [
"defaultAggregation" => get_config("local_treestudyplan","aggregation_mode"), "defaultAggregation" => get_config("local_treestudyplan","aggregation_mode"),
"editMode" => $PAGE->user_is_editing()
]]); ]]);
/** /**
@ -168,7 +167,6 @@ print $OUTPUT->header();
v-model='activestudyplan' v-model='activestudyplan'
@moved="movedStudyplan" @moved="movedStudyplan"
@toggletoolbox="toggletoolbox" @toggletoolbox="toggletoolbox"
:initeditmode="initialEditMode"
@pagechanged="onPageChange" @pagechanged="onPageChange"
></t-studyplan> ></t-studyplan>
<div v-else-if='loadingstudyplan' class="spinner-border text-primary" role="status"> <div v-else-if='loadingstudyplan' class="spinner-border text-primary" role="status">

View File

@ -17,3 +17,10 @@
} }
} }
/* Hide the edit button on studyplan pages */
body.path-local-treestudyplan {
.editmode-switch-form > * {
visibility: hidden;
}
}

View File

@ -32,6 +32,11 @@
color: gold; color: gold;
} }
/* Hide the edit button on studyplan pages */
body.path-local-treestudyplan .editmode-switch-form > * {
visibility: hidden;
}
/******************* /*******************
* *
* Invite manager * Invite manager

View File

@ -98,8 +98,6 @@ if ($CFG->debugdeveloper) {
} }
$PAGE->requires->js_call_amd('local_treestudyplan/page-view-plan', 'init', [$studyplancontext->id, $categoryid]); $PAGE->requires->js_call_amd('local_treestudyplan/page-view-plan', 'init', [$studyplancontext->id, $categoryid]);
// Disable edit switch.
$PAGE->theme->haseditswitch = false;
/** /**
* Shortcut function to provide translations * Shortcut function to provide translations
* *