From cfa209a24b88d00dfd7dcef31776af9530f125a2 Mon Sep 17 00:00:00 2001 From: iziram Date: Tue, 30 May 2023 10:17:49 +0200 Subject: [PATCH] =?UTF-8?q?Assiduites=20:=20pr=C3=A9f=C3=A9rences=20-=20gr?= =?UTF-8?q?anularit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/forms/main/config_assiduites.py | 4 +- app/static/js/assiduites.js | 173 +--------------- app/templates/assiduites/config_assiduites.j2 | 1 + app/templates/assiduites/minitimeline.j2 | 190 +++++++++++++++++- app/templates/assiduites/timeline.j2 | 22 +- app/views/assiduites.py | 13 +- app/views/scodoc.py | 3 + 7 files changed, 221 insertions(+), 185 deletions(-) diff --git a/app/forms/main/config_assiduites.py b/app/forms/main/config_assiduites.py index 26126f2e6..1c18135d5 100644 --- a/app/forms/main/config_assiduites.py +++ b/app/forms/main/config_assiduites.py @@ -30,7 +30,7 @@ Formulaire configuration Module Assiduités """ from flask_wtf import FlaskForm -from wtforms import SubmitField +from wtforms import SubmitField, DecimalField from wtforms.fields.simple import StringField from wtforms.widgets import TimeInput import datetime @@ -82,5 +82,7 @@ class ConfigAssiduitesForm(FlaskForm): lunch_time = TimeField("Heure de midi (date pivot entre Matin et Après Midi)") afternoon_time = TimeField("Fin de la journée") + tick_time = DecimalField("Granularité de la Time Line (temps en minutes)", places=0) + submit = SubmitField("Valider") cancel = SubmitField("Annuler", render_kw={"formnovalidate": True}) diff --git a/app/static/js/assiduites.js b/app/static/js/assiduites.js index 3848af838..2a2325603 100644 --- a/app/static/js/assiduites.js +++ b/app/static/js/assiduites.js @@ -439,9 +439,9 @@ function hideLoader() { */ function toTime(time) { let heure = Math.floor(time); - let minutes = (time - heure) * 60; - if (minutes < 1) { - minutes = "00"; + let minutes = Math.round((time - heure) * 60); + if (minutes < 10) { + minutes = `0${minutes}`; } if (heure < 10) { heure = `0${heure}`; @@ -997,7 +997,6 @@ function generateEtudRow(
- 13h
{ - const startDate = moment(assiduité.date_debut); - const endDate = moment(assiduité.date_fin); - - if (startDate.isBefore(dayStart)) { - startDate.startOf("day").add(8, "hours"); - } - - if (endDate.isAfter(dayEnd)) { - endDate.startOf("day").add(18, "hours"); - } - - const block = document.createElement("div"); - block.className = "mini-timeline-block"; - - const startOffset = moment.duration(startDate.diff(dayStart)).asMinutes(); - const duration = moment.duration(endDate.diff(startDate)).asMinutes(); - const leftPercentage = (startOffset / dayDuration) * 100; - const widthPercentage = (duration / dayDuration) * 100; - - block.style.left = `${leftPercentage}%`; - block.style.width = `${widthPercentage}%`; - - if (assiduité.etat != "CRENEAU") { - if (isSingleEtud()) { - block.addEventListener("click", () => { - let deb = startDate.hours() + startDate.minutes() / 60; - let fin = endDate.hours() + endDate.minutes() / 60; - deb = Math.max(8, deb); - fin = Math.min(18, fin); - - setPeriodValues(deb, fin); - updateSelectedSelect(getCurrentAssiduiteModuleImplId()); - updateJustifyBtn(); - }); - } - //ajouter affichage assiduites on over - setupAssiduiteBuble(block, assiduité); - } - - const action = (justificatifs) => { - if (justificatifs.length > 0) { - let j = "invalid_justified"; - - justificatifs.forEach((ju) => { - if (ju.etat == "VALIDE") { - j = "justified"; - } - }); - - block.classList.add(j); - } - }; - - if (assiduité.etudid) { - getJustificatifFromPeriod( - { - deb: new moment.tz(assiduité.date_debut, TIMEZONE), - fin: new moment.tz(assiduité.date_fin, TIMEZONE), - }, - assiduité.etudid, - action - ); - } - - switch (assiduité.etat) { - case "PRESENT": - block.classList.add("present"); - break; - case "RETARD": - block.classList.add("retard"); - break; - case "ABSENT": - block.classList.add("absent"); - break; - case "CRENEAU": - block.classList.add("creneau"); - break; - default: - block.style.backgroundColor = "white"; - } - - timeline.appendChild(block); - }); - - return timeline; -} - -/** - * Ajout de la visualisation des assiduités de la mini timeline - * @param {HTMLElement} el l'élément survollé - * @param {Assiduité} assiduite l'assiduité représentée par l'élément - */ -function setupAssiduiteBuble(el, assiduite) { - if (!assiduite) return; - el.addEventListener("mouseenter", (event) => { - const bubble = document.querySelector(".assiduite-bubble"); - bubble.className = "assiduite-bubble"; - bubble.classList.add("is-active", assiduite.etat.toLowerCase()); - - bubble.innerHTML = ""; - - const idDiv = document.createElement("div"); - idDiv.className = "assiduite-id"; - idDiv.textContent = `ID: ${assiduite.assiduite_id}`; - bubble.appendChild(idDiv); - - const periodDivDeb = document.createElement("div"); - periodDivDeb.className = "assiduite-period"; - periodDivDeb.textContent = `${formatDateModal(assiduite.date_debut)}`; - bubble.appendChild(periodDivDeb); - const periodDivFin = document.createElement("div"); - periodDivFin.className = "assiduite-period"; - periodDivFin.textContent = `${formatDateModal(assiduite.date_fin)}`; - bubble.appendChild(periodDivFin); - - const stateDiv = document.createElement("div"); - stateDiv.className = "assiduite-state"; - stateDiv.textContent = `État: ${assiduite.etat.capitalize()}`; - bubble.appendChild(stateDiv); - - const userIdDiv = document.createElement("div"); - userIdDiv.className = "assiduite-user_id"; - userIdDiv.textContent = `saisi le ${formatDateModal( - assiduite.entry_date, - "à" - )} \npar ${getUserFromId(assiduite.user_id)}`; - bubble.appendChild(userIdDiv); - - bubble.style.left = `${event.clientX - bubble.offsetWidth / 2}px`; - bubble.style.top = `${event.clientY + 20}px`; - }); - el.addEventListener("mouseout", () => { - const bubble = document.querySelector(".assiduite-bubble"); - bubble.classList.remove("is-active"); - }); -} - /** * Mise à jour d'une ligne étudiant * @param {String | Number} etudid l'identifiant de l'étudiant diff --git a/app/templates/assiduites/config_assiduites.j2 b/app/templates/assiduites/config_assiduites.j2 index 92d9dd246..417d0275f 100644 --- a/app/templates/assiduites/config_assiduites.j2 +++ b/app/templates/assiduites/config_assiduites.j2 @@ -14,6 +14,7 @@ {{ wtf.form_field(form.morning_time) }} {{ wtf.form_field(form.lunch_time) }} {{ wtf.form_field(form.afternoon_time) }} + {{ wtf.form_field(form.tick_time) }}
{{ wtf.form_field(form.submit) }} {{ wtf.form_field(form.cancel) }} diff --git a/app/templates/assiduites/minitimeline.j2 b/app/templates/assiduites/minitimeline.j2 index 27f30b40c..ebde4d0c6 100644 --- a/app/templates/assiduites/minitimeline.j2 +++ b/app/templates/assiduites/minitimeline.j2 @@ -3,6 +3,189 @@