fix redirect back spatial plannings

This commit is contained in:
arifal
2025-03-13 15:48:53 +07:00
parent 0258ca9f04
commit e97b7eb70d
7 changed files with 34 additions and 70 deletions

View File

@@ -8,6 +8,7 @@ import GeneralTable from "../../table-generator.js";
const tableElement = document.getElementById("spatial-planning-data-table");
const canUpdate = tableElement.getAttribute("data-updater") === "1";
const canDelete = tableElement.getAttribute("data-destroyer") === "1";
let menuId = document.getElementById("menuId").value;
const dataSpatialPlanningColumns = [
"No",
@@ -23,7 +24,7 @@ const dataSpatialPlanningColumns = [
widht: "120px",
formatter: function (cell, row) {
const id = row.cells[8].data;
const model = "data/spatial-plannings";
const model = "data/web-spatial-plannings";
let actionButtons = '<div class="d-flex justify-items-end gap-10">';
let hasPrivilege = false;
@@ -34,7 +35,8 @@ const dataSpatialPlanningColumns = [
actionButtons += `
<button class="btn btn-warning me-2 btn-edit"
data-id="${id}"
data-model="${model}">
data-model="${model}"
data-menu="${menuId}">
<i class='bx bx-edit'></i>
</button>`;
}
@@ -49,10 +51,14 @@ const dataSpatialPlanningColumns = [
</button>`;
}
actionButtons += '</div>';
actionButtons += "</div>";
// Jika tidak memiliki akses, tampilkan teks "No Privilege"
return gridjs.html(hasPrivilege ? actionButtons : '<span class="text-muted">No Privilege</span>');
return gridjs.html(
hasPrivilege
? actionButtons
: '<span class="text-muted">No Privilege</span>'
);
},
},
];

View File

@@ -5,6 +5,7 @@ document.addEventListener("DOMContentLoaded", function () {
const modalButton = document.querySelector(".btn-modal");
const form = document.querySelector("form#create-update-form");
var authLogo = document.querySelector(".auth-logo");
let menuId = document.getElementById("menuId").value;
if (!saveButton || !form) return;
@@ -73,7 +74,7 @@ document.addEventListener("DOMContentLoaded", function () {
}, 3000);
setTimeout(() => {
window.location.href = "/data/web-spatial-plannings";
window.location.href = `/data/web-spatial-plannings?menu_id=${menuId}`;
}, 3000);
} else {
if (authLogo) {

View File

@@ -28,6 +28,7 @@ console.log(dropzonePreviewNode);
.getAttribute("content")}`,
},
init: function () {
let menuId = document.getElementById("menuId").value;
// Listen for the success event
this.on("success", function (file, response) {
console.log("File successfully uploaded:", file);
@@ -39,7 +40,7 @@ console.log(dropzonePreviewNode);
"Upload Files";
// Tunggu sebentar lalu reload halaman
setTimeout(() => {
window.location.href = "/data/web-spatial-plannings";
window.location.href = `/data/web-spatial-plannings?menu_id=${menuId}`;
}, 2000);
});
// Listen for the error event