fix exclude is_valid false and clickable dashboard simbg

This commit is contained in:
arifal
2025-08-19 14:06:07 +07:00
parent e9a70a827c
commit 3cddd271c8
6 changed files with 278 additions and 30 deletions

View File

@@ -43,19 +43,29 @@ class PbgTasks {
handleFilterDatatable() {
const form = document.getElementById("filter-form");
const filterSelect = document.getElementById("filter-select");
const yearSelect = document.getElementById("year-select");
const resetBtn = document.getElementById("reset-filter");
const urlParams = new URLSearchParams(window.location.search);
const initialFilter = urlParams.get("filter") || "";
const initialYear = urlParams.get("year") || "2025"; // Default to 2025
this.initTableRequestAssignment(initialFilter); // Initial load with query param
// Set initial year if not in URL
if (!urlParams.get("year")) {
yearSelect.value = "2025";
}
this.initTableRequestAssignment(initialFilter, initialYear); // Initial load with query params
form.addEventListener("submit", (e) => {
e.preventDefault();
const selectedFilter = filterSelect.value;
const selectedYear = yearSelect.value;
const params = new URLSearchParams(window.location.search);
params.set("filter", selectedFilter);
params.set("year", selectedYear);
// Update the URL without reloading
window.history.replaceState(
@@ -64,12 +74,27 @@ class PbgTasks {
`${location.pathname}?${params}`
);
// Call the method again with the selected filter
this.initTableRequestAssignment(selectedFilter);
// Call the method again with the selected filter and year
this.initTableRequestAssignment(selectedFilter, selectedYear);
});
// Handle reset button
resetBtn.addEventListener("click", (e) => {
e.preventDefault();
// Reset form values
filterSelect.value = "";
yearSelect.value = "2025";
// Clear URL parameters
window.history.replaceState({}, "", location.pathname);
// Reload table with default values
this.initTableRequestAssignment("", "2025");
});
}
initTableRequestAssignment(filterValue = "") {
initTableRequestAssignment(filterValue = "", yearValue = "2025") {
const urlBase = `${GlobalConfig.apiHost}/api/request-assignments`;
// Ambil token
@@ -179,7 +204,7 @@ class PbgTasks {
},
sort: true,
server: {
url: `${urlBase}?filter=${filterValue}`,
url: `${urlBase}?filter=${filterValue}&year=${yearValue}`,
credentials: "include",
headers: {
Authorization: `Bearer ${token}`,
@@ -365,7 +390,18 @@ class PbgTasks {
self.toastMessage.innerText =
"File uploaded successfully!";
self.toast.show();
self.initTableRequestAssignment();
// Get current filter and year values to refresh table
const currentFilter =
document.getElementById("filter-select").value ||
"";
const currentYear =
document.getElementById("year-select").value ||
"2025";
self.initTableRequestAssignment(
currentFilter,
currentYear
);
});
dz.on("error", (file, message) => {