fix redirect back umkm

This commit is contained in:
arifal
2025-03-13 15:39:32 +07:00
parent 0116147e06
commit 0258ca9f04
7 changed files with 42 additions and 44 deletions

View File

@@ -7,6 +7,7 @@ import GeneralTable from "../../table-generator.js";
const tableElement = document.getElementById("umkm-data-table");
const canUpdate = tableElement.getAttribute("data-updater") === "1";
const canDelete = tableElement.getAttribute("data-destroyer") === "1";
let menuId = document.getElementById("menuId").value;
const dataUMKMColumns = [
"No",
@@ -31,24 +32,25 @@ const dataUMKMColumns = [
{
name: "Actions",
widht: "120px",
formatter: function(cell, row) {
formatter: function (cell, row) {
const id = row.cells[19].data;
const model = "data/umkm";
const model = "data/web-umkm";
let actionButtons = '<div class="d-flex justify-items-end gap-10">';
let hasPrivilege = false;
// Tampilkan tombol Edit jika user punya akses update
if (canUpdate) {
hasPrivilege = true;
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>`;
}
// Tampilkan tombol Delete jika user punya akses delete
if (canDelete) {
hasPrivilege = true;
@@ -58,13 +60,17 @@ const dataUMKMColumns = [
<i class='bx bxs-trash'></i>
</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>'
);
},
},
];
document.addEventListener("DOMContentLoaded", () => {
@@ -103,4 +109,4 @@ document.addEventListener("DOMContentLoaded", () => {
};
table.init();
});
});

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;
@@ -74,7 +75,7 @@ document.addEventListener("DOMContentLoaded", function () {
}, 2000);
setTimeout(() => {
window.location.href = "/data/web-umkm";
window.location.href = `/data/web-umkm?menu_id=${menuId}`;
}, 1000);
} 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-umkm";
window.location.href = `/data/web-umkm?menu_id=${menuId}`;
}, 2000);
});
// Listen for the error event