change filter year on dashboard to dropdown

This commit is contained in:
arifal
2025-02-13 01:17:22 +07:00
parent 9efb6c346e
commit a9afb47f08
2 changed files with 14 additions and 11 deletions

View File

@@ -8,10 +8,10 @@ class BigData {
try {
this.filterYear = new Date().getFullYear(); // Set initial year
let yearInput = document.querySelector("#yearPicker");
let yearSelect = document.querySelector("#yearPicker");
let filterButton = document.querySelector("#btnFilterYear");
if (!yearInput || !filterButton) {
if (!yearSelect || !filterButton) {
console.error(
"Element #yearPicker or #btnFilterYear not found."
);
@@ -19,18 +19,15 @@ class BigData {
}
// Set default value for input
yearInput.value = this.filterYear;
yearSelect.value = this.filterYear;
// Handle manual input (pressing Enter)
yearInput.addEventListener("keypress", (event) => {
if (event.key === "Enter") {
this.updateYear(yearInput.value);
}
yearSelect.addEventListener("change", () => {
this.updateYear(yearSelect.value);
});
// Handle button click
filterButton.addEventListener("click", () => {
this.updateYear(yearInput.value);
this.updateYear(yearSelect.value);
});
console.log("init filter this year", this.filterYear);