diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index 4131e7f7..5037a31d 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -610,6 +610,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 bf3d821b..3848af83 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 b67fd0b6..590c83a5 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)