Fixed default aggregation setting not working

This commit is contained in:
PMKuipers 2023-09-09 21:06:11 +02:00
parent 9fee6fb8b5
commit 4a358728e5
7 changed files with 25 additions and 8 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

@ -49,14 +49,24 @@ let strings = load_strings({
* Initialize the Page * Initialize the Page
* @param {int} contextid The context we should attempt to work in (1:1 related to the category) * @param {int} contextid The context we should attempt to work in (1:1 related to the category)
* @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context) * @param {int} categoryid The category we shoud attempt to work in (1:1 related to the context)
* @param {object} options Options to be passed to this script
*/ */
export function init(contextid,categoryid) { export function init(contextid,categoryid,options) {
// Make sure the id's are numeric and integer // Make sure the id's are numeric and integer
if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;} if(undefined === contextid || !Number.isInteger(Number(contextid)) || contextid < 1 ){ contextid = 1;}
else { contextid = Number(contextid);} // ensure a numeric value instead of string else { contextid = Number(contextid);} // ensure a numeric value instead of string
if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;} if(undefined === categoryid || !Number.isInteger(Number(categoryid))){ categoryid = 0;}
else { categoryid = Number(categoryid);} // ensure a numeric value instead of string else { categoryid = Number(categoryid);} // ensure a numeric value instead of string
debug.info("options",options);
if ( options !== null && typeof options === 'object' && !Array.isArray(options) ) {
if ( !options.defaultAggregation ) {
options.defaultAggregation = "core";
}
} else {
options = { defaultAggregation: "core"};
}
const in_systemcontext = (contextid <= 1); const in_systemcontext = (contextid <= 1);
// Setup the initial Vue app for this page // Setup the initial Vue app for this page
@ -73,7 +83,7 @@ export function init(contextid,categoryid) {
startdate: '2020-08-01', startdate: '2020-08-01',
enddate: '', enddate: '',
context: contextid, context: contextid,
aggregation: 'bistate', aggregation: options.defaultAggregation,
aggregation_config: '', aggregation_config: '',
} }
}, },

View File

@ -528,6 +528,10 @@ export default {
'contextid': { 'contextid': {
type: Number, type: Number,
default: 1 default: 1
},
'defaultAggregation': {
type: String,
default: "core",
} }
}, },
data() { data() {
@ -554,7 +558,7 @@ export default {
periods : 4, periods : 4,
startdate: (new Date()).getFullYear() + '-08-01', startdate: (new Date()).getFullYear() + '-08-01',
enddate: ((new Date()).getFullYear()+1) + '-08-01', enddate: ((new Date()).getFullYear()+1) + '-08-01',
aggregation: 'bistate', aggregation: this.defaultAggregation,
aggregation_config: '', aggregation_config: '',
}, },
aggregation_parsed: { aggregation_parsed: {

View File

@ -78,7 +78,9 @@ $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/boot
if ($CFG->debugdeveloper) { if ($CFG->debugdeveloper) {
$PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css')); $PAGE->requires->css(new moodle_url($CFG->wwwroot.'/local/treestudyplan/css/devstyles.css'));
} }
$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"),
]]);
$catlist = courseservice::list_accessible_categories_with_usage("edit"); $catlist = courseservice::list_accessible_categories_with_usage("edit");
@ -133,6 +135,7 @@ print $OUTPUT->header();
v-model="create.studyplan" v-model="create.studyplan"
type="button" type="button"
variant="primary" variant="primary"
default-aggregation="<?php print(get_config("local_treestudyplan","aggregation_mode")); ?>"
:contextid='contextid' :contextid='contextid'
><i class='fa fa-plus'></i> <?php t("studyplan_add");?></t-studyplan-edit> ><i class='fa fa-plus'></i> <?php t("studyplan_add");?></t-studyplan-edit>
<b-button v-if='!activestudyplan && !loadingstudyplan' <b-button v-if='!activestudyplan && !loadingstudyplan'