Fixed context switch not working in chrome
This commit is contained in:
parent
b8c0f910c1
commit
7b980405f3
2
amd/build/page-edit-plan.min.js
vendored
2
amd/build/page-edit-plan.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
2
amd/build/page-view-plan.min.js
vendored
2
amd/build/page-view-plan.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -233,11 +233,14 @@ export function init(contextid,categoryid,options) {
|
|||
app.selectStudyplan(newstudyplan);
|
||||
}
|
||||
},
|
||||
switchContext(cat){
|
||||
switchContext(ctxid){
|
||||
const params = new URLSearchParams(location.search);
|
||||
params.delete('categoryid');
|
||||
params.set('contextid', cat.context_id);
|
||||
window.location.search = params.toString();
|
||||
params.set('contextid', ctxid);
|
||||
setTimeout(() => {
|
||||
// Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.
|
||||
window.location.href = window.location.pathname + "?" + params.toString();
|
||||
},50);
|
||||
},
|
||||
selectStudyplan(studyplan){
|
||||
// fetch studyplan
|
||||
|
|
|
@ -126,11 +126,14 @@ export function init(contextid,categoryid) {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
switchContext(cat){
|
||||
switchContext(ctxid){
|
||||
const params = new URLSearchParams(location.search);
|
||||
params.delete('categoryid');
|
||||
params.set('contextid', cat.context_id);
|
||||
window.location.search = params.toString();
|
||||
params.set('contextid', ctxid);
|
||||
setTimeout(() => {
|
||||
// Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.
|
||||
window.location.href = window.location.pathname + "?" + params.toString();
|
||||
},50);
|
||||
},
|
||||
closeStudyplan() {
|
||||
app.activestudyplan = null;
|
||||
|
|
|
@ -314,6 +314,11 @@ class courseservice extends \external_api {
|
|||
$contextids[] = $r->context_id;
|
||||
}
|
||||
|
||||
// Add system context to list if needed.
|
||||
if (!in_array(1,$contextids)) {
|
||||
array_unshift($contextids,1);
|
||||
}
|
||||
|
||||
$rs->close();
|
||||
|
||||
$cats = [];
|
||||
|
@ -339,6 +344,8 @@ class courseservice extends \external_api {
|
|||
}
|
||||
if(!$found) {
|
||||
array_unshift($contextids,$refctxid);
|
||||
debug::write("After two");
|
||||
debug::print_r($contextids);
|
||||
}
|
||||
} catch(\dml_missing_record_exception $x) {
|
||||
// ignore context
|
||||
|
@ -358,7 +365,10 @@ class courseservice extends \external_api {
|
|||
if ($operation == "edit" && $ctxid == $refctxid) {
|
||||
// Include direct children for navigation purposes
|
||||
foreach ($cat->get_children() as $ccat) {
|
||||
$cats[] = $ccat;
|
||||
$ccatctx = \context_coursecat::instance($ccat->id);
|
||||
if (!in_array($ccatctx->id,$contextids)) {
|
||||
$cats[] = $ccat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -408,6 +418,11 @@ class courseservice extends \external_api {
|
|||
}
|
||||
$rs->close();
|
||||
|
||||
// Add system context to list if needed.
|
||||
if (!in_array(1,$contextids)) {
|
||||
array_unshift($contextids,1);
|
||||
}
|
||||
|
||||
$cats = [];
|
||||
// If the reference context id is not in the list, push it there
|
||||
if ($refctxid > 1 && !in_array($refctxid, $contextids)) {
|
||||
|
@ -451,7 +466,10 @@ class courseservice extends \external_api {
|
|||
if ($operation == "view" && $ctxid == $refctxid) {
|
||||
// Include direct children for navigation purposes
|
||||
foreach ($cat->get_children() as $ccat) {
|
||||
$cats[] = $ccat;
|
||||
$ccatctx = \context_coursecat::instance($ccat->id);
|
||||
if (!in_array($ccatctx->id,$contextids)) {
|
||||
$cats[] = $ccat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,9 +107,9 @@ print $OUTPUT->header();
|
|||
</div>
|
||||
<div v-cloak>
|
||||
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
|
||||
<b-form-select text='<?php print($contextname);?>' :value="contextid">
|
||||
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id" @click='switchContext(ctx)'
|
||||
:active="ctx.context_id == contextid" :class="(ctx.studyplancount > 0) ? 'font-weight-bold' : ''"
|
||||
<b-form-select text='<?php print($contextname);?>' :value="contextid" @change='switchContext'>
|
||||
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id"
|
||||
:class="(ctx.studyplancount > 0) ? 'font-weight-bold' : '' + (ctx.context_id == contextid)?' active':''"
|
||||
><span v-for="(p, i) in ctx.category.path"
|
||||
><span v-if="i>0"> / </span>{{ p }}</span> <span>({{ ctx.studyplancount }})</span>
|
||||
</b-form-select-option>
|
||||
|
|
|
@ -104,9 +104,9 @@ print $OUTPUT->header();
|
|||
</div>
|
||||
<div v-cloak>
|
||||
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
|
||||
<b-form-select text='<?php print($contextname);?>' :value="contextid">
|
||||
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id" @click='switchContext(ctx)'
|
||||
:active="ctx.context_id == contextid" :class="(ctx.studyplancount > 0) ? 'font-weight-bold' : ''"
|
||||
<b-form-select text='<?php print($contextname);?>' :value="contextid" @change='switchContext'>
|
||||
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id"
|
||||
:class="(ctx.studyplancount > 0) ? 'font-weight-bold' : '' + (ctx.context_id == contextid)?' active':''"
|
||||
><span v-for="(p, i) in ctx.category.path"><span v-if="i>0"> / </span>{{ p }}</span>
|
||||
<span>({{ ctx.studyplancount }})</span></b-form-select-option>
|
||||
</b-form-select>
|
||||
|
|
Loading…
Reference in New Issue
Block a user