Fixed context switch not working in chrome
This commit is contained in:
parent
b8c0f910c1
commit
7b980405f3
9 changed files with 43 additions and 19 deletions
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);
|
app.selectStudyplan(newstudyplan);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
switchContext(cat){
|
switchContext(ctxid){
|
||||||
const params = new URLSearchParams(location.search);
|
const params = new URLSearchParams(location.search);
|
||||||
params.delete('categoryid');
|
params.delete('categoryid');
|
||||||
params.set('contextid', cat.context_id);
|
params.set('contextid', ctxid);
|
||||||
window.location.search = params.toString();
|
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){
|
selectStudyplan(studyplan){
|
||||||
// fetch studyplan
|
// fetch studyplan
|
||||||
|
|
|
@ -126,11 +126,14 @@ export function init(contextid,categoryid) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
switchContext(cat){
|
switchContext(ctxid){
|
||||||
const params = new URLSearchParams(location.search);
|
const params = new URLSearchParams(location.search);
|
||||||
params.delete('categoryid');
|
params.delete('categoryid');
|
||||||
params.set('contextid', cat.context_id);
|
params.set('contextid', ctxid);
|
||||||
window.location.search = params.toString();
|
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() {
|
closeStudyplan() {
|
||||||
app.activestudyplan = null;
|
app.activestudyplan = null;
|
||||||
|
|
|
@ -314,6 +314,11 @@ class courseservice extends \external_api {
|
||||||
$contextids[] = $r->context_id;
|
$contextids[] = $r->context_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add system context to list if needed.
|
||||||
|
if (!in_array(1,$contextids)) {
|
||||||
|
array_unshift($contextids,1);
|
||||||
|
}
|
||||||
|
|
||||||
$rs->close();
|
$rs->close();
|
||||||
|
|
||||||
$cats = [];
|
$cats = [];
|
||||||
|
@ -339,6 +344,8 @@ class courseservice extends \external_api {
|
||||||
}
|
}
|
||||||
if(!$found) {
|
if(!$found) {
|
||||||
array_unshift($contextids,$refctxid);
|
array_unshift($contextids,$refctxid);
|
||||||
|
debug::write("After two");
|
||||||
|
debug::print_r($contextids);
|
||||||
}
|
}
|
||||||
} catch(\dml_missing_record_exception $x) {
|
} catch(\dml_missing_record_exception $x) {
|
||||||
// ignore context
|
// ignore context
|
||||||
|
@ -358,10 +365,13 @@ class courseservice extends \external_api {
|
||||||
if ($operation == "edit" && $ctxid == $refctxid) {
|
if ($operation == "edit" && $ctxid == $refctxid) {
|
||||||
// Include direct children for navigation purposes
|
// Include direct children for navigation purposes
|
||||||
foreach ($cat->get_children() as $ccat) {
|
foreach ($cat->get_children() as $ccat) {
|
||||||
|
$ccatctx = \context_coursecat::instance($ccat->id);
|
||||||
|
if (!in_array($ccatctx->id,$contextids)) {
|
||||||
$cats[] = $ccat;
|
$cats[] = $ccat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (\dml_missing_record_exception $x) {
|
} catch (\dml_missing_record_exception $x) {
|
||||||
// ignore context
|
// ignore context
|
||||||
}
|
}
|
||||||
|
@ -408,6 +418,11 @@ class courseservice extends \external_api {
|
||||||
}
|
}
|
||||||
$rs->close();
|
$rs->close();
|
||||||
|
|
||||||
|
// Add system context to list if needed.
|
||||||
|
if (!in_array(1,$contextids)) {
|
||||||
|
array_unshift($contextids,1);
|
||||||
|
}
|
||||||
|
|
||||||
$cats = [];
|
$cats = [];
|
||||||
// If the reference context id is not in the list, push it there
|
// If the reference context id is not in the list, push it there
|
||||||
if ($refctxid > 1 && !in_array($refctxid, $contextids)) {
|
if ($refctxid > 1 && !in_array($refctxid, $contextids)) {
|
||||||
|
@ -451,10 +466,13 @@ class courseservice extends \external_api {
|
||||||
if ($operation == "view" && $ctxid == $refctxid) {
|
if ($operation == "view" && $ctxid == $refctxid) {
|
||||||
// Include direct children for navigation purposes
|
// Include direct children for navigation purposes
|
||||||
foreach ($cat->get_children() as $ccat) {
|
foreach ($cat->get_children() as $ccat) {
|
||||||
|
$ccatctx = \context_coursecat::instance($ccat->id);
|
||||||
|
if (!in_array($ccatctx->id,$contextids)) {
|
||||||
$cats[] = $ccat;
|
$cats[] = $ccat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (\dml_missing_record_exception $x) {
|
} catch (\dml_missing_record_exception $x) {
|
||||||
// ignore context
|
// ignore context
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,9 +107,9 @@ print $OUTPUT->header();
|
||||||
</div>
|
</div>
|
||||||
<div v-cloak>
|
<div v-cloak>
|
||||||
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
|
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
|
||||||
<b-form-select text='<?php print($contextname);?>' :value="contextid">
|
<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" @click='switchContext(ctx)'
|
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id"
|
||||||
:active="ctx.context_id == contextid" :class="(ctx.studyplancount > 0) ? 'font-weight-bold' : ''"
|
:class="(ctx.studyplancount > 0) ? 'font-weight-bold' : '' + (ctx.context_id == contextid)?' active':''"
|
||||||
><span v-for="(p, i) in ctx.category.path"
|
><span v-for="(p, i) in ctx.category.path"
|
||||||
><span v-if="i>0"> / </span>{{ p }}</span> <span>({{ ctx.studyplancount }})</span>
|
><span v-if="i>0"> / </span>{{ p }}</span> <span>({{ ctx.studyplancount }})</span>
|
||||||
</b-form-select-option>
|
</b-form-select-option>
|
||||||
|
|
|
@ -104,9 +104,9 @@ print $OUTPUT->header();
|
||||||
</div>
|
</div>
|
||||||
<div v-cloak>
|
<div v-cloak>
|
||||||
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
|
<div v-if='!activestudyplan && usedcontexts' class='ml-3 mb-3'>
|
||||||
<b-form-select text='<?php print($contextname);?>' :value="contextid">
|
<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" @click='switchContext(ctx)'
|
<b-form-select-option v-for='ctx in usedcontexts' :key='ctx.id' :value="ctx.context_id"
|
||||||
:active="ctx.context_id == contextid" :class="(ctx.studyplancount > 0) ? 'font-weight-bold' : ''"
|
: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 v-for="(p, i) in ctx.category.path"><span v-if="i>0"> / </span>{{ p }}</span>
|
||||||
<span>({{ ctx.studyplancount }})</span></b-form-select-option>
|
<span>({{ ctx.studyplancount }})</span></b-form-select-option>
|
||||||
</b-form-select>
|
</b-form-select>
|
||||||
|
|
Loading…
Reference in a new issue