Assiduites : fix partiel bug differee

This commit is contained in:
Iziram 2023-09-21 17:25:57 +02:00
parent 7b62ab8784
commit b8f7037804

View File

@ -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();