From 310582cd06dc92f342f7cbf471f30f324a09e3ef Mon Sep 17 00:00:00 2001 From: l_samenv Date: Tue, 27 Aug 2024 15:42:34 +0200 Subject: [PATCH] Changed setInitialDate in dates_popup --- client/components/dates_popup/dates_popup.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/components/dates_popup/dates_popup.js b/client/components/dates_popup/dates_popup.js index c5bd3cc..00ac9d8 100644 --- a/client/components/dates_popup/dates_popup.js +++ b/client/components/dates_popup/dates_popup.js @@ -54,23 +54,26 @@ class DatesPopup extends HTMLElement{ } show(){ + this.setInitialDates(); this.style.visibility = "visible"; } - setInitialDate(){ + setInitialDates(){ let currentDate = new Date(); + let correctedCurrentDate = new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate())); let dateInput = this.getElementsByClassName("input-date")[0]; - let dateDayBefore = new Date(currentDate - DatesPopup.DAY); + let dateDayBefore = new Date(correctedCurrentDate - DatesPopup.DAY); dateInput.valueAsDate = dateDayBefore; + + this.getElementsByClassName("input-date")[0].max = correctedCurrentDate.toISOString().split("T")[0]; // sets the max to today (set only at app start) + } connectedCallback(){ this.render(); - this.setInitialDate(); this.hide(); this.getElementsByTagName("img")[0].onclick = () => {this.hide();}; this.getElementsByClassName("go-to-now-button")[0].onclick = () => {this.doGoToNowCallback();}; - this.getElementsByClassName("input-date")[0].max = new Date().toISOString().split("T")[0]; // sets the max to today (set only at app start) this.getElementsByClassName("jump-button")[0].onclick = () => {this.doJumpCallback();}; }