From 75ce1ccd31a9410509bbfa1fe7ff7a91200eb80e Mon Sep 17 00:00:00 2001 From: Iziram Date: Fri, 24 May 2024 09:56:05 +0200 Subject: [PATCH] =?UTF-8?q?Assiduit=C3=A9=20:=20signal=5Fassiduite=5Fgroup?= =?UTF-8?q?=20:=20sauvegarde=20auto=20timeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/assiduites/widgets/timeline.j2 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/templates/assiduites/widgets/timeline.j2 b/app/templates/assiduites/widgets/timeline.j2 index 02113e99..d7acdbe8 100644 --- a/app/templates/assiduites/widgets/timeline.j2 +++ b/app/templates/assiduites/widgets/timeline.j2 @@ -134,6 +134,7 @@ timelineContainer.removeEventListener("mousemove", onMouseMove); handleMoving = false; func_call(); + savePeriodInLocalStorage(); } timelineContainer.addEventListener("mousemove", onMouseMove); @@ -167,6 +168,7 @@ snapHandlesToQuarters(); timelineContainer.removeEventListener("mousemove", onMouseMove); func_call(); + savePeriodInLocalStorage(); } timelineContainer.addEventListener("mousemove", onMouseMove); timelineContainer.addEventListener("touchmove", onMouseMove); @@ -265,6 +267,7 @@ snapHandlesToQuarters(); updatePeriodTimeLabel() func_call(); + savePeriodInLocalStorage(); } function snapHandlesToQuarters() { @@ -310,9 +313,23 @@ } } + function savePeriodInLocalStorage(){ + const dates = getPeriodValues(); + localStorage.setItem("sco-timeline-values", JSON.stringify(dates)); + } + + function loadPeriodFromLocalStorage(){ + const dates = JSON.parse(localStorage.getItem("sco-timeline-values")); + if(dates){ + setPeriodValues(...dates); + }else{ + setPeriodValues(t_start, t_start + period_default); + } + } + createTicks(); - setPeriodValues(t_start, t_start + period_default); + loadPeriodFromLocalStorage(); {% if heures %} let [heure_deb, heure_fin] = [{{ heures | safe }}]