Date input for jump is the last set

This commit is contained in:
l_samenv
2024-08-29 14:35:27 +02:00
parent a4aaffa299
commit 6ed8529e1b

View File

@ -54,24 +54,31 @@ class DatesPopup extends HTMLElement{
}
show(){
this.setInitialDates();
this.setMaxInputDate();
this.style.visibility = "visible";
}
setInitialDates(){
getCorrectedCurrentDate(){
let currentDate = new Date();
let correctedCurrentDate = new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()));
return correctedCurrentDate;
}
setInitialInputDate(){
let dateInput = this.getElementsByClassName("input-date")[0];
let dateDayBefore = new Date(correctedCurrentDate - DatesPopup.DAY);
let dateDayBefore = new Date(this.getCorrectedCurrentDate() - 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)
setMaxInputDate(){
let dateInput = this.getElementsByClassName("input-date")[0];
dateInput.max = this.getCorrectedCurrentDate().toISOString().split("T")[0]; // sets the max to today (set each time the pop up is displayed)
}
connectedCallback(){
this.render();
this.hide();
this.setInitialInputDate();
this.getElementsByTagName("img")[0].onclick = () => {this.hide();};
this.getElementsByClassName("go-to-now-button")[0].onclick = () => {this.doGoToNowCallback();};
this.getElementsByClassName("jump-button")[0].onclick = () => {this.doJumpCallback();};