Fixed issues with location hash not updatieng on going back

This commit is contained in:
PMKuipers 2023-09-03 17:12:44 +02:00
parent 641356be31
commit ef29eb6209
9 changed files with 16 additions and 12 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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -189,7 +189,7 @@ export function init(contextid,categoryid) {
methods: { methods: {
closeStudyplan() { closeStudyplan() {
app.activestudyplan = null; app.activestudyplan = null;
location.hash = ''; window.location.hash = '';
}, },
movedStudyplan(plan,from,to) { movedStudyplan(plan,from,to) {
// reload the page in the new context (needed, since a number of links are not reactive in the page) // reload the page in the new context (needed, since a number of links are not reactive in the page)
@ -220,7 +220,7 @@ export function init(contextid,categoryid) {
app.activestudyplan = ProcessStudyplan(response,true); app.activestudyplan = ProcessStudyplan(response,true);
debug.info('studyplan processed'); debug.info('studyplan processed');
app.loadingstudyplan = false; app.loadingstudyplan = false;
location.hash = app.activestudyplan.id; window.location.hash = app.activestudyplan.id;
}).fail(function(error){ }).fail(function(error){
notification.exception(error); notification.exception(error);
app.loadingstudyplan = false; app.loadingstudyplan = false;

View file

@ -17,6 +17,7 @@ import {ProcessStudyplan} from './studyplan-processor';
import RVComponents from './report-viewer-components'; import RVComponents from './report-viewer-components';
Vue.use(RVComponents); Vue.use(RVComponents);
import TSComponents from './treestudyplan-components';
import ModalComponents from './modedit-modal'; import ModalComponents from './modedit-modal';
Vue.use(ModalComponents); Vue.use(ModalComponents);
@ -85,7 +86,7 @@ export function init(contextid,categoryid) {
}); });
app.studyplans = response; app.studyplans = response;
// load studyplan from hash if applicable // load studyplan from hash if applicable
const hash = location.hash.replace('#',''); const hash = window.location.hash.replace('#','');
const parts = hash.split("-"); const parts = hash.split("-");
if(!!parts && parts.length > 0){ if(!!parts && parts.length > 0){
@ -135,6 +136,7 @@ export function init(contextid,categoryid) {
app.associatedstudents = []; app.associatedstudents = [];
app.studentstudyplan = []; app.studentstudyplan = [];
app.displayedstudyplan = null; app.displayedstudyplan = null;
window.location.hash = '';
}, },
selectStudyplan(studyplan,studentid){ selectStudyplan(studyplan,studentid){
@ -151,7 +153,7 @@ export function init(contextid,categoryid) {
app.activestudyplan = ProcessStudyplan(response,true); app.activestudyplan = ProcessStudyplan(response,true);
app.displayedstudyplan = app.activestudyplan; app.displayedstudyplan = app.activestudyplan;
app.loadingstudyplan = false; app.loadingstudyplan = false;
location.hash = app.activestudyplan.id; window.location.hash = app.activestudyplan.id;
call([{ call([{
methodname: 'local_treestudyplan_all_associated', methodname: 'local_treestudyplan_all_associated',
args: { studyplan_id: studyplan.id} args: { studyplan_id: studyplan.id}
@ -183,7 +185,7 @@ export function init(contextid,categoryid) {
app.studentstudyplan = ProcessStudyplan(response,false); app.studentstudyplan = ProcessStudyplan(response,false);
app.displayedstudyplan = app.studentstudyplan; app.displayedstudyplan = app.studentstudyplan;
app.loadingstudyplan = false; app.loadingstudyplan = false;
location.hash = app.activestudyplan.id + "-" + student.id; window.location.hash = app.activestudyplan.id + "-" + student.id;
}).fail(function(error){ }).fail(function(error){
notification.exception(error); notification.exception(error);
app.loadingstudyplan = false; app.loadingstudyplan = false;
@ -195,6 +197,7 @@ export function init(contextid,categoryid) {
app.selectedstudent = null; app.selectedstudent = null;
app.studentstudyplan = null; app.studentstudyplan = null;
app.displayedstudyplan = app.activestudyplan; app.displayedstudyplan = app.activestudyplan;
window.location.hash = app.activestudyplan.id;
} }
}, },

View file

@ -8,7 +8,8 @@
import {SimpleLine} from './simpleline/simpleline'; import {SimpleLine} from './simpleline/simpleline';
import {get_strings} from 'core/str'; import {get_strings} from 'core/str';
import {load_strings, format_date} from './util/string-helper'; import {load_strings} from './util/string-helper';
import {format_date} from './util/date-helper';
import {call} from 'core/ajax'; import {call} from 'core/ajax';
import notification from 'core/notification'; import notification from 'core/notification';
import {svgarcpath} from './util/svgarc'; import {svgarcpath} from './util/svgarc';