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

View File

@ -1198,7 +1198,7 @@ export default {
* T-STUDYPLAN
*/
Vue.component('t-studyplan', {
props: [ 'value', 'index', 'initeditmode'],
props: [ 'value', 'index'],
data() {
return {
config: {
@ -1274,17 +1274,15 @@ export default {
const self = this;
// 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
ItemEventBus.$on('editModeSet', this.onMoodleEditModeChanged);
ItemEventBus.$on('coursechange', () => {
self.$emit('pagechanged',this.selectedpage);
});
},
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
this.edit.studyline.editmode = true;
}*/
this.edit.studyline.editmode = this.initeditmode;
}
this.$root.$emit('redrawLines');
this.$emit('pagechanged',this.selectedpage);
},
@ -1298,9 +1296,6 @@ export default {
}
},
methods: {
onMoodleEditModeChanged(mode){
this.edit.studyline.editmode = mode;
},
columns(page) {
return 1+ (page.periods * 2);
},

View File

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

View File

@ -80,7 +80,7 @@ if ($studyplancontext->id > 1) {
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)) {
@ -94,7 +94,6 @@ if ($CFG->debugdeveloper) {
}
$PAGE->requires->js_call_amd('local_treestudyplan/page-edit-plan', 'init', [$studyplancontext->id, $categoryid, [
"defaultAggregation" => get_config("local_treestudyplan","aggregation_mode"),
"editMode" => $PAGE->user_is_editing()
]]);
/**
@ -168,7 +167,6 @@ print $OUTPUT->header();
v-model='activestudyplan'
@moved="movedStudyplan"
@toggletoolbox="toggletoolbox"
:initeditmode="initialEditMode"
@pagechanged="onPageChange"
></t-studyplan>
<div v-else-if='loadingstudyplan' class="spinner-border text-primary" role="status">

View File

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

View File

@ -32,6 +32,11 @@
color: gold;
}
/* Hide the edit button on studyplan pages */
body.path-local-treestudyplan .editmode-switch-form > * {
visibility: hidden;
}
/*******************
*
* 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]);
// Disable edit switch.
$PAGE->theme->haseditswitch = false;
/**
* Shortcut function to provide translations
*