From db5fe4f640fd03c7b0b2b1a59cc94bb566a8c4d9 Mon Sep 17 00:00:00 2001 From: iziram Date: Thu, 13 Apr 2023 17:31:13 +0200 Subject: [PATCH] =?UTF-8?q?assiduit=C3=A9=20etudiant=20:=20debut=20justifi?= =?UTF-8?q?cation=20rapide?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/assiduites.js | 68 +++++++++++++++++++ .../assiduites/moduleimpl_dynamic_selector.j2 | 4 +- .../assiduites/signal_assiduites_etud.j2 | 12 +++- 3 files changed, 80 insertions(+), 4 deletions(-) diff --git a/app/static/js/assiduites.js b/app/static/js/assiduites.js index b6339b32..c4b78ac5 100644 --- a/app/static/js/assiduites.js +++ b/app/static/js/assiduites.js @@ -1722,3 +1722,71 @@ function getCurrentAssiduiteModuleImplId() { } return ""; } + +function getCurrentAssiduite(etudid) { + const field = document.querySelector( + `fieldset.btns_field.single[etudid='${etudid}']` + ); + + if (!field) return null; + + const assiduite_id = parseInt(field.getAttribute("assiduite_id")); + const type = field.getAttribute("type"); + + if (type == "edition") { + let assi = null; + assiduites[etudid].forEach((a) => { + if (a.assiduite_id === assiduite_id) { + assi = a; + } + }); + return assi; + } else { + return null; + } +} + +// <<== Gestion de la justification ==>> + +function getJustificatifFromPeriod(date) { + let justifs = []; + sync_get( + getUrl() + + `/api/justificatifs/${etudid}/query?date_debut=${date.deb.format()}&date_fin=${date.fin.format()}`, + (data) => { + justifs = data; + } + ); + + return justifs; +} + +function updateJustifieButton(isJustified, isDisabled = true) { + const btn = document.getElementById("justif-rapide"); + if (isJustified) { + btn.classList.add("justifie"); + } else { + btn.classList.remove("justifie"); + } + + if (isDisabled) { + btn.setAttribute("disabled", "true"); + } else { + btn.removeAttribute("disabled"); + } +} + +function fastJustify(assiduite) { + const period = { + deb: new moment.tz(assiduite.date_debut, TIMEZONE), + fin: new moment.tz(assiduite.date_fin, TIMEZONE), + }; + const justifs = getJustificatifFromPeriod(period); + + if (justifs.length > 0) { + //modifier l'assiduité + } else { + //créer un nouveau justificatif + // Afficher prompt -> demander raison et état + } +} diff --git a/app/templates/assiduites/moduleimpl_dynamic_selector.j2 b/app/templates/assiduites/moduleimpl_dynamic_selector.j2 index 263b2d64..3fcf07d5 100644 --- a/app/templates/assiduites/moduleimpl_dynamic_selector.j2 +++ b/app/templates/assiduites/moduleimpl_dynamic_selector.j2 @@ -98,9 +98,7 @@ } function updateSelectedSelect(moduleimpl_id) { - const select = document.getElementById('moduleimpl_select'); - select.querySelector("option[selected]").removeAttribute("selected"); - select.querySelector(`option[value="${moduleimpl_id}"]`).setAttribute('selected', 'true'); + document.getElementById('moduleimpl_select').value = moduleimpl_id; } diff --git a/app/templates/assiduites/signal_assiduites_etud.j2 b/app/templates/assiduites/signal_assiduites_etud.j2 index e697a288..00b4bd21 100644 --- a/app/templates/assiduites/signal_assiduites_etud.j2 +++ b/app/templates/assiduites/signal_assiduites_etud.j2 @@ -40,7 +40,11 @@ {% include "assiduites/timeline.j2" %} - {% include "assiduites/moduleimpl_dynamic_selector.j2" %} + +
+ {% include "assiduites/moduleimpl_dynamic_selector.j2" %} + +
@@ -75,6 +79,7 @@ getSingleEtud({{ sco.etud.id }}); actualizeEtud({{ sco.etud.id }}); updateSelect() + @@ -82,6 +87,11 @@ .rouge { color: crimson; } + + .justifie { + background-color: rgb(104, 104, 252); + color: whitesmoke; + } {% endblock %}