From 1c0d0baf150c439a645d97a7bed65ab40f40fca7 Mon Sep 17 00:00:00 2001 From: iziram Date: Wed, 14 Jun 2023 17:53:19 +0200 Subject: [PATCH] =?UTF-8?q?Assiduites=20:=20Fixes=20+=20fin=20page=20diff?= =?UTF-8?q?=C3=A9r=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/css/assiduites.css | 2 + app/static/js/assiduites.js | 74 ++- app/templates/assiduites/differee.j2 | 496 +++++++++++------- .../assiduites/signal_assiduites_diff.j2 | 3 +- app/templates/assiduites/timeline.j2 | 2 +- app/templates/assiduites/toast.j2 | 19 + 6 files changed, 367 insertions(+), 229 deletions(-) diff --git a/app/static/css/assiduites.css b/app/static/css/assiduites.css index 2b8e1d573f..be4a8842c0 100644 --- a/app/static/css/assiduites.css +++ b/app/static/css/assiduites.css @@ -231,6 +231,8 @@ -webkit-appearance: none; appearance: none; + cursor: pointer; + } .rbtn::before { diff --git a/app/static/js/assiduites.js b/app/static/js/assiduites.js index e543fad6f4..2bafa4cd72 100644 --- a/app/static/js/assiduites.js +++ b/app/static/js/assiduites.js @@ -195,7 +195,7 @@ function sync_post(path, data, success, errors) { * @param {CallableFunction} errors fonction à effectuer en cas d'échec */ function async_post(path, data, success, errors) { - $.ajax({ + return $.ajax({ async: true, type: "POST", url: path, @@ -334,27 +334,22 @@ function executeMassActionQueue() { }; //On exécute les fonctions de queue - let color; - switch (currentMassActionEtat.toUpperCase()) { - case "PRESENT": - color = "#6bdb83"; - break; - case "ABSENT": - color = "#F1A69C"; - break; - case "RETARD": - color = "#f0c865"; - break; - default: - color = "#AAA"; - break; - } let count = 0; if (currentMassActionEtat == "remove") { count += supprimer(); const span = document.createElement("span"); - span.innerHTML = `${count} assiduités ont été supprimées.`; - pushToast(generateToast(span, color, 5)); + if (count > 0) { + span.innerHTML = `${count} assiduités ont été supprimées.`; + } else { + span.innerHTML = `Aucune assiduité n'a été supprimée.`; + } + pushToast( + generateToast( + span, + getToastColorFromEtat(currentMassActionEtat.toUpperCase()), + 5 + ) + ); } else { count += create(); count += edit(); @@ -363,10 +358,22 @@ function executeMassActionQueue() { ? "En retard" : currentMassActionEtat; const span = document.createElement("span"); - span.innerHTML = `${count} étudiants ont été mis ${etat - .capitalize() - .trim()}`; - pushToast(generateToast(span, color, 5)); + if (count > 0) { + span.innerHTML = `${count} étudiants ont été mis ${etat + .capitalize() + .trim()}`; + } else { + span.innerHTML = `Aucun étudiant n'a été mis ${etat + .capitalize() + .trim()}`; + } + pushToast( + generateToast( + span, + getToastColorFromEtat(currentMassActionEtat.toUpperCase()), + 5 + ) + ); } //On récupère les assiduités puis on regénère les lignes d'étudiants getAssiduitesFromEtuds(true); @@ -1105,30 +1112,15 @@ function assiduiteAction(element) { etatAffiche = "L'assiduité de %etud% a été retirée."; } - let color; - - switch (etat.toUpperCase()) { - case "PRESENT": - color = "#6bdb83"; - break; - case "ABSENT": - color = "#F1A69C"; - break; - case "RETARD": - color = "#f0c865"; - break; - default: - color = "#AAA"; - break; - } - const nom_prenom = `${etuds[etudid].nom.toUpperCase()} ${etuds[ etudid ].prenom.capitalize()}`; const span = document.createElement("span"); span.innerHTML = etatAffiche.replace("%etud%", nom_prenom); - pushToast(generateToast(span, color, 5)); + pushToast( + generateToast(span, getToastColorFromEtat(etat.toUpperCase()), 5) + ); } actualizeEtud(etudid, !isSingleEtud); @@ -1322,7 +1314,7 @@ function getUserFromId(id) { let name = "Non Renseigné"; - sync_get(`/ScoDoc/api/user/${id}`, (data) => { + sync_get(getUrl() + `/api/user/${id}`, (data) => { if (data.nom != "" && data.prenom != "") { name = `${data.nom} ${data.prenom}`; } else { diff --git a/app/templates/assiduites/differee.j2 b/app/templates/assiduites/differee.j2 index 756bdf88eb..e1a356ae9a 100644 --- a/app/templates/assiduites/differee.j2 +++ b/app/templates/assiduites/differee.j2 @@ -11,7 +11,7 @@
{{etud.nomprenom}} - + No Img
{% endfor %} @@ -76,7 +76,9 @@ text-align: center; width: 225px; border: 1px solid #ddd; - display: inline-block; + display: flex; + justify-content: center; + align-content: center; } .tr { @@ -213,6 +215,36 @@ cursor: not-allowed; } + + .th.error:hover .col-error { + display: block; + z-index: 2000; + background-color: crimson; + width: 100%; + min-height: 25%; + bottom: -25%; + transition: all 1s; + } + + .col-error { + position: absolute; + display: none; + } + + .mass { + display: flex; + justify-content: space-evenly; + align-items: center; + } + + .mass input { + outline: none; + border: none; + } + + .rbtn:disabled { + opacity: 0.7; + } \ No newline at end of file diff --git a/app/templates/assiduites/signal_assiduites_diff.j2 b/app/templates/assiduites/signal_assiduites_diff.j2 index be5f4a40b3..9735aa8a03 100644 --- a/app/templates/assiduites/signal_assiduites_diff.j2 +++ b/app/templates/assiduites/signal_assiduites_diff.j2 @@ -5,4 +5,5 @@ {% include "assiduites/alert.j2" %} {% include "assiduites/prompt.j2" %} -{% include "assiduites/conflict.j2" %} \ No newline at end of file +{% include "assiduites/conflict.j2" %} +{% include "assiduites/toast.j2" %} \ No newline at end of file diff --git a/app/templates/assiduites/timeline.j2 b/app/templates/assiduites/timeline.j2 index 5a53ce6514..4f77c86d17 100644 --- a/app/templates/assiduites/timeline.j2 +++ b/app/templates/assiduites/timeline.j2 @@ -56,7 +56,7 @@ function numberToTime(num) { const integer = Math.floor(num); - const decimal = (num % 1) * 60; + const decimal = Math.round((num % 1) * 60); let dec = `:${decimal}`; if (decimal < 10) { diff --git a/app/templates/assiduites/toast.j2 b/app/templates/assiduites/toast.j2 index f1a0becffd..e15994529b 100644 --- a/app/templates/assiduites/toast.j2 +++ b/app/templates/assiduites/toast.j2 @@ -92,6 +92,25 @@ } + function getToastColorFromEtat(etat) { + let color; + switch (etat.toUpperCase()) { + case "PRESENT": + color = "#6bdb83"; + break; + case "ABSENT": + color = "#F1A69C"; + break; + case "RETARD": + color = "#f0c865"; + break; + default: + color = "#AAA"; + break; + } + return color; + } + \ No newline at end of file