Date input for jump is the last set
This commit is contained in:
@ -54,24 +54,31 @@ class DatesPopup extends HTMLElement{
|
|||||||
}
|
}
|
||||||
|
|
||||||
show(){
|
show(){
|
||||||
this.setInitialDates();
|
this.setMaxInputDate();
|
||||||
this.style.visibility = "visible";
|
this.style.visibility = "visible";
|
||||||
}
|
}
|
||||||
|
|
||||||
setInitialDates(){
|
getCorrectedCurrentDate(){
|
||||||
let currentDate = new Date();
|
let currentDate = new Date();
|
||||||
let correctedCurrentDate = new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()));
|
let correctedCurrentDate = new Date(Date.UTC(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()));
|
||||||
|
return correctedCurrentDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
setInitialInputDate(){
|
||||||
let dateInput = this.getElementsByClassName("input-date")[0];
|
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;
|
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(){
|
connectedCallback(){
|
||||||
this.render();
|
this.render();
|
||||||
this.hide();
|
this.hide();
|
||||||
|
this.setInitialInputDate();
|
||||||
this.getElementsByTagName("img")[0].onclick = () => {this.hide();};
|
this.getElementsByTagName("img")[0].onclick = () => {this.hide();};
|
||||||
this.getElementsByClassName("go-to-now-button")[0].onclick = () => {this.doGoToNowCallback();};
|
this.getElementsByClassName("go-to-now-button")[0].onclick = () => {this.doGoToNowCallback();};
|
||||||
this.getElementsByClassName("jump-button")[0].onclick = () => {this.doJumpCallback();};
|
this.getElementsByClassName("jump-button")[0].onclick = () => {this.doJumpCallback();};
|
||||||
|
Reference in New Issue
Block a user