From a04403cd0e2e0c8be35499bfcc04503d55db11dd Mon Sep 17 00:00:00 2001 From: iziram Date: Tue, 22 Aug 2023 16:06:56 +0200 Subject: [PATCH] Assiduites : fixes select annee cal + saisie par null --- app/templates/assiduites/pages/calendrier.j2 | 12 +++++++----- app/templates/assiduites/widgets/minitimeline.j2 | 6 +++++- app/views/assiduites.py | 11 +++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/app/templates/assiduites/pages/calendrier.j2 b/app/templates/assiduites/pages/calendrier.j2 index 76ab5eb3..ce8e9e0f 100644 --- a/app/templates/assiduites/pages/calendrier.j2 +++ b/app/templates/assiduites/pages/calendrier.j2 @@ -336,19 +336,21 @@ } const defAnnee = {{ annee }} + let annees = {{ annees | safe }} + annees = annees.filter((x, i) => annees.indexOf(x) === i) const etudid = {{ sco.etud.id }}; const nonwork = [{{ nonworkdays | safe }}]; window.onload = () => { const select = document.querySelector('#annee'); - for (let i = defAnnee + 1; i > defAnnee - 6; i--) { + annees.forEach((a) => { const opt = document.createElement("option"); - opt.value = i + "", - opt.textContent = i + ""; - if (i === defAnnee) { + opt.value = a + "", + opt.textContent = `${a} - ${a + 1}`; + if (a === defAnnee) { opt.selected = true; } select.appendChild(opt) - } + }) setterAnnee(defAnnee) }; diff --git a/app/templates/assiduites/widgets/minitimeline.j2 b/app/templates/assiduites/widgets/minitimeline.j2 index 811fd193..f3febd83 100644 --- a/app/templates/assiduites/widgets/minitimeline.j2 +++ b/app/templates/assiduites/widgets/minitimeline.j2 @@ -162,7 +162,11 @@ userIdDiv.textContent = `saisi le ${formatDateModal( assiduite.entry_date, "à" - )} \npar ${assiduite.user_id}`; + )}`; + + if (assiduite.user_id != null) { + userIdDiv.textContent += `\npar ${assiduite.user_id}` + } bubble.appendChild(userIdDiv); bubble.style.left = `${event.clientX - bubble.offsetWidth / 2}px`; diff --git a/app/views/assiduites.py b/app/views/assiduites.py index b11e6b11..0969c4ae 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -417,6 +417,16 @@ def calendrier_etud(): ], ) + annees: list[int] = sorted( + [ins.formsemestre.date_debut.year for ins in etud.formsemestre_inscriptions], + reverse=True, + ) + + annees_str: str = "[" + for ann in annees: + annees_str += f"{ann}," + annees_str += "]" + return HTMLBuilder( header, render_template( @@ -425,6 +435,7 @@ def calendrier_etud(): annee=scu.annee_scolaire(), nonworkdays=_non_work_days(), minitimeline=_mini_timeline(), + annees=annees_str, ), ).build()