From b8f7037804a0ce55a432f10dc7c3e9cf87912f96 Mon Sep 17 00:00:00 2001 From: Iziram Date: Thu, 21 Sep 2023 17:25:57 +0200 Subject: [PATCH] Assiduites : fix partiel bug differee --- app/templates/assiduites/widgets/differee.j2 | 41 ++++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/app/templates/assiduites/widgets/differee.j2 b/app/templates/assiduites/widgets/differee.j2 index 523c4a827..33e5356a3 100644 --- a/app/templates/assiduites/widgets/differee.j2 +++ b/app/templates/assiduites/widgets/differee.j2 @@ -96,6 +96,14 @@ display: flex; } + .td[assiduite_id='insc'] * { + display: none; + } + + .td[assiduite_id='insc']::after { + content: "Etudiant non inscrit"; + } + .sticky { position: sticky; left: 0; @@ -278,6 +286,8 @@ currentDate = moment(currentDate).tz(TIMEZONE).format("YYYY-MM-DDTHH:mm"); } + const inscriptionsModule = {}; + function createColumn(dateStart = "", dateEnd = "", moduleimpl_id = "") { let table = document.getElementById("studentTable"); let th = document.createElement("div"); @@ -561,6 +571,8 @@ const d_debut = moment(inputDeb).tz(TIMEZONE); const d_fin = moment(inputFin).tz(TIMEZONE); + const moduleimpl_id = col.querySelector("#moduleimpl_select").value; + const periode = { deb: d_debut, fin: d_fin, @@ -573,9 +585,12 @@ }); setEtatLine(td, "") const etu = td.parentElement.getAttribute('etudid'); + const inscriptionModule = ["", "autre"].indexOf(moduleimpl_id) !== -1 ? true : checkInscriptionModule(moduleimpl_id, etu); const conflits = getAssiduitesConflict(etu, periode); - - if (conflits.length == 0) { + if (!inscriptionModule) { + td.setAttribute('assiduite_id', "insc"); + } + else if (conflits.length == 0) { td.setAttribute('assiduite_id', "-1"); } else if (conflits.length == 1 && isConflictSameAsPeriod(conflits[0], periode)) { const assi = conflits[0]; @@ -587,7 +602,6 @@ const inputs = [...td.querySelectorAll('input')]; inputs.forEach((i) => { i.disabled = true; - }) } }) @@ -871,7 +885,7 @@ const { moduleimpl, deb, fin } = getAssiduitesCol(colid, false); const lines = [...document.querySelectorAll(`[assiduite_id][colid='${colid}']`)].filter((el) => { - return el.getAttribute('assiduite_id') != "conflit"; + return ["conflit", "insc"].indexOf(el.getAttribute('assiduite_id')) == -1; }) const toCreate = lines.filter((el) => { return el.getAttribute('assiduite_id') == '-1' }) @@ -1019,6 +1033,25 @@ }) } + function checkInscriptionModule(moduleimpl_id, etudid) { + if (!inscriptionsModule.hasOwnProperty(moduleimpl_id)) { + const path = getUrl() + `/api/moduleimpl/${moduleimpl_id}/inscriptions`; + sync_get( + path, + (data, status) => { + inscriptionsModule[moduleimpl_id] = data; + }, + (data, status) => { + //error + console.error(data, status); + errorAlert(); + } + ); + } + const etudsInscrits = inscriptionsModule[moduleimpl_id].map((i) => i.etudid); + return etudsInscrits.indexOf(Number(etudid)) !== -1; + } + window.addEventListener('load', () => { document.getElementById("addColumn").addEventListener("click", () => { createColumn();