From 4d5c1a84c3b64b4df227f3fe861f0af7680aade2 Mon Sep 17 00:00:00 2001 From: iziram Date: Wed, 17 May 2023 20:46:10 +0200 Subject: [PATCH] =?UTF-8?q?Assiduites=20:=20ajout=20pr=C3=A9f=C3=A9rence?= =?UTF-8?q?=20:=20dur=C3=A9e=20cr=C3=A9neau?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_preferences.py | 11 +++++++++++ app/static/js/assiduites.js | 4 +++- app/templates/assiduites/timeline.j2 | 12 ++++++++---- app/views/assiduites.py | 5 ++++- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index 52a1bf418..99080600b 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -620,6 +620,17 @@ class BasePreferences(object): "category": "assi", }, ), + ( + "periode_defaut", + { + "initvalue": 2.0, + "size": 10, + "title": "Durée par défaut d'un créneau", + "type": "float", + "category": "assi", + "only_global": True, + }, + ), ( "etat_defaut", { diff --git a/app/static/js/assiduites.js b/app/static/js/assiduites.js index bf3d821b8..3848af838 100644 --- a/app/static/js/assiduites.js +++ b/app/static/js/assiduites.js @@ -1263,7 +1263,9 @@ function actualizeEtud(etudid) { */ function generateAllEtudRow() { if (isSingleEtud()) { - actualizeEtud(etudid); + try { + actualizeEtud(etudid); + } catch (ignored) {} return; } diff --git a/app/templates/assiduites/timeline.j2 b/app/templates/assiduites/timeline.j2 index b67fd0b6c..590c83a53 100644 --- a/app/templates/assiduites/timeline.j2 +++ b/app/templates/assiduites/timeline.j2 @@ -9,8 +9,10 @@ const timelineContainer = document.querySelector(".timeline-container"); const periodTimeLine = document.querySelector(".period"); - const t_start = {{ t_start }} - const t_end = {{ t_end }} + const t_start = {{ t_start }}; + const t_end = {{ t_end }}; + + const period_default = {{ periode_defaut }}; function createTicks() { let i = t_start @@ -157,7 +159,7 @@ const computedValues = [Math.max(startValue, t_start), Math.min(t_end, endValue)] if (computedValues[0] > t_end || computedValues[1] < t_start) { - return [8, 10] + return [t_start, min(t_end, t_start + period_default)] } if (computedValues[1] - computedValues[0] <= 0.25 && computedValues[1] < t_end - 0.25) { @@ -168,6 +170,8 @@ } function setPeriodValues(deb, fin) { + deb = snapToQuarter(deb) + fin = snapToQuarter(fin) let leftPercentage = (deb - t_start) / (t_end - t_start) * 100 let widthPercentage = (fin - deb) / (t_end - t_start) * 100 periodTimeLine.style.left = `${leftPercentage}%` @@ -199,7 +203,7 @@ } createTicks(); - setPeriodValues(8, 9) + setPeriodValues(t_start, t_start + period_default)