Skip to content
Snippets Groups Projects
Commit 55e7527e authored by Emmanuel Viennet's avatar Emmanuel Viennet
Browse files

Merge branch 'jmplace-t1054'

parents 094edc62 9895bfec
No related branches found
No related tags found
No related merge requests found
...@@ -1009,7 +1009,7 @@ def _form_saisie_notes( ...@@ -1009,7 +1009,7 @@ def _form_saisie_notes(
H.append( H.append(
f"""<a href="{url_for("notes.moduleimpl_status", scodoc_dept=g.scodoc_dept, f"""<a href="{url_for("notes.moduleimpl_status", scodoc_dept=g.scodoc_dept,
moduleimpl_id=modimpl.id) moduleimpl_id=modimpl.id)
}" class="btn btn-primary">Terminer</a> }" class="btn btn-primary link-terminer">Terminer</a>
""" """
) )
if tf.canceled(): if tf.canceled():
......
// Formulaire saisie des notes // Formulaire saisie des notes
let nbSaving = 0; // nombre de requêtes en cours
function incSaving() {
nbSaving++;
// disable button 'Terminer'
let anchor = document.querySelector(".link-terminer")
anchor.style.pointerEvents = "none";
anchor.style.color = "gray";
anchor.style.textDecoration = "none";
anchor.style.cursor = "not-allowed";
}
function decSaving() {
nbSaving--;
if (nbSaving <= 0) {
// re-enable bouton 'Terminer'
let anchor = document.querySelector(".link-terminer");
anchor.style.pointerEvents = "unset";
anchor.style.color = "unset";
anchor.style.textDecoration = "unset";
anchor.style.cursor = "unset";
}
}
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
let noteInputs = document.querySelectorAll("#formnotes .note"); let noteInputs = document.querySelectorAll("#formnotes .note");
noteInputs.forEach(function (input) { noteInputs.forEach(function (input) {
...@@ -54,15 +78,13 @@ function valid_note(e) { ...@@ -54,15 +78,13 @@ function valid_note(e) {
} }
} }
let isSaving = false; // true si requête en cours
async function save_note(elem, v, etudid) { async function save_note(elem, v, etudid) {
let evaluation_id = document.querySelector("#formnotes_evaluation_id").getAttribute("value"); let evaluation_id = document.querySelector("#formnotes_evaluation_id").getAttribute("value");
let formsemestre_id = document.querySelector("#formnotes_formsemestre_id").getAttribute("value"); let formsemestre_id = document.querySelector("#formnotes_formsemestre_id").getAttribute("value");
var scoMsg = document.getElementById("sco_msg"); var scoMsg = document.getElementById("sco_msg");
scoMsg.innerHTML = "en cours..."; scoMsg.innerHTML = "en cours...";
scoMsg.style.display = "block"; scoMsg.style.display = "block";
isSaving = true; // Set the flag to true when the request starts incSaving(); // update counter to show one more saving in progress
try { try {
const response = await fetch( const response = await fetch(
SCO_URL + "../api/evaluation/" + evaluation_id + "/notes/set", SCO_URL + "../api/evaluation/" + evaluation_id + "/notes/set",
...@@ -109,7 +131,7 @@ async function save_note(elem, v, etudid) { ...@@ -109,7 +131,7 @@ async function save_note(elem, v, etudid) {
console.error("Fetch error:", error); console.error("Fetch error:", error);
sco_message("Erreur réseau: valeur non enregistrée"); sco_message("Erreur réseau: valeur non enregistrée");
} finally { } finally {
isSaving = false; // Reset the flag when the request is complete decSaving(); // update counter to show one saving in progress less. May re-enable 'Terminer' button
} }
} }
...@@ -121,7 +143,7 @@ window.addEventListener('beforeunload', function (e) { ...@@ -121,7 +143,7 @@ window.addEventListener('beforeunload', function (e) {
valid_note.call(input); valid_note.call(input);
} }
}); });
if (isSaving) { if (nbSaving > 0) {
// Display a confirmation dialog // Display a confirmation dialog
const confirmationMessage = 'Des modifications sont en cours de sauvegarde. Êtes-vous sûr de vouloir quitter cette page ?'; const confirmationMessage = 'Des modifications sont en cours de sauvegarde. Êtes-vous sûr de vouloir quitter cette page ?';
e.preventDefault(); // Standard for most modern browsers e.preventDefault(); // Standard for most modern browsers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment