diff --git a/app/scodoc/sco_saisie_notes.py b/app/scodoc/sco_saisie_notes.py
index 40bb4a4e1d37fc85eb7e8cee7c0d53fb72fc1717..a119c8e5037e2c36e9b1e9bb5d560f3a1ca7c519 100644
--- a/app/scodoc/sco_saisie_notes.py
+++ b/app/scodoc/sco_saisie_notes.py
@@ -1009,7 +1009,7 @@ def _form_saisie_notes(
H.append(
f"""<a href="{url_for("notes.moduleimpl_status", scodoc_dept=g.scodoc_dept,
moduleimpl_id=modimpl.id)
- }" class="btn btn-primary">Terminer</a>
+ }" class="btn btn-primary link-terminer">Terminer</a>
"""
)
if tf.canceled():
diff --git a/app/static/js/saisie_notes.js b/app/static/js/saisie_notes.js
index b040a9f012c28657c4012f589f7121c2b067aa64..8bbd62e2f7fffaa9407c0d9dc7754051d05ca97d 100644
--- a/app/static/js/saisie_notes.js
+++ b/app/static/js/saisie_notes.js
@@ -1,5 +1,23 @@
// Formulaire saisie des notes
+let nbSaving = 0; // nombre de requêtes en cours
+
+function incSaving() {
+ nbSaving++;
+ // disable button 'Terminer'
+ anchor = document.querySelector(".link-terminer");
+ anchor.style.display = "none"
+}
+
+function decSaving() {
+ nbSaving--;
+ if (nbSaving <= 0) {
+ // re-enable bouton 'Terminer'
+ anchor = document.querySelector(".link-terminer");
+ anchor.style.display = "";
+ }
+}
+
document.addEventListener("DOMContentLoaded", function () {
let noteInputs = document.querySelectorAll("#formnotes .note");
noteInputs.forEach(function (input) {
@@ -54,15 +72,13 @@ function valid_note(e) {
}
}
-let isSaving = false; // true si requête en cours
-
async function save_note(elem, v, etudid) {
let evaluation_id = document.querySelector("#formnotes_evaluation_id").getAttribute("value");
let formsemestre_id = document.querySelector("#formnotes_formsemestre_id").getAttribute("value");
var scoMsg = document.getElementById("sco_msg");
scoMsg.innerHTML = "en cours...";
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 {
const response = await fetch(
SCO_URL + "../api/evaluation/" + evaluation_id + "/notes/set",
@@ -109,7 +125,7 @@ async function save_note(elem, v, etudid) {
console.error("Fetch error:", error);
sco_message("Erreur réseau: valeur non enregistrée");
} 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 +137,7 @@ window.addEventListener('beforeunload', function (e) {
valid_note.call(input);
}
});
- if (isSaving) {
+ if (nbSaving > 0) {
// Display a confirmation dialog
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