Formulaire jury BUT: vérifie sortie sans enregistrement (JS) #425

This commit is contained in:
Emmanuel Viennet 2022-12-25 16:40:05 -03:00 committed by iziram
parent c8c05ecd77
commit 9fb70aef5d
2 changed files with 26 additions and 1 deletions

View File

@ -117,3 +117,28 @@ window.addEventListener("beforeunload", function (e) {
return confirmationMessage; return confirmationMessage;
} }
}); });
// ----- Etat du formulaire jury pour éviter sortie sans enregistrer
let FORM_STATE = "";
// Une chaine décrivant l'état du form
function get_form_state() {
let codes = [];
// il n'y a que des <select>
document.querySelectorAll("select").forEach(sel => codes.push(sel.value));
return codes.join();
}
$('document').ready(function () {
FORM_STATE = get_form_state();
});
function is_modified() {
return FORM_STATE != get_form_state();
}
window.addEventListener("beforeunload", function (e) {
if (is_modified()) {
var confirmationMessage = 'Changements non enregistrés !';
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
}
});

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.4.7" SCOVERSION = "9.4.20"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"