Make sure forms are not considered dirty before loading a new page.

This commit is contained in:
PMKuipers 2024-02-07 23:10:19 +01:00
parent 626e2c9aac
commit 32a09a7c44
4 changed files with 8 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,8 @@
import {get_string,get_strings} from 'core/str';
import {call} from 'core/ajax';
import notification from 'core/notification';
import {resetAllFormDirtyStates} from 'core_form/changechecker';
import Vue from './vue/vue';
@ -220,10 +222,9 @@ export function init(contextid,categoryid,options) {
const params = new URLSearchParams(location.search);
params.delete('categoryid');
params.set("contextid", newstudyplan.context_id);
setTimeout(() => {
// Reload page in a timeout to give other form javasccript the change to remove the beforeunload handler.
window.location = window.location.pathname + "?" + params.toString() + "#" + newstudyplan.id;
},50);
// Make sure the form is no longer dirty before reloading the page - avoid beforeunload handler triggering.
resetAllFormDirtyStates();
window.location = window.location.pathname + "?" + params.toString() + "#" + newstudyplan.id;
} else {
app.studyplans.push(newstudyplan);
app.selectStudyplan(newstudyplan.id);

View File

@ -22,7 +22,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'local_treestudyplan'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494).
$plugin->version = 2024020700; // YYYYMMDDHH (year, month, day, iteration).
$plugin->version = 2024020702; // YYYYMMDDHH (year, month, day, iteration).
$plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11).
$plugin->release = "1.1.0";