fix pdam redirect back and advertisement partial update redirect

This commit is contained in:
arifal
2025-03-13 13:57:53 +07:00
parent e5db2294b4
commit e47ab36d5e
14 changed files with 72 additions and 78 deletions

View File

@@ -6,6 +6,7 @@ class CreateCustomer {
initCreateCustomer() {
const toastNotification = document.getElementById("toastNotification");
const toast = new bootstrap.Toast(toastNotification);
let menuId = document.getElementById("menuId").value;
document
.getElementById("btnCreateCustomer")
.addEventListener("click", async function () {
@@ -41,7 +42,7 @@ class CreateCustomer {
result.message;
toast.show();
setTimeout(() => {
window.location.href = "/data/customers";
window.location.href = `/data/customers?menu_id=${menuId}`;
}, 2000);
} else {
let error = await response.json();

View File

@@ -6,6 +6,7 @@ class UpdateCustomer {
initUpdateCustomer() {
const toastNotification = document.getElementById("toastNotification");
const toast = new bootstrap.Toast(toastNotification);
let menuId = document.getElementById("menuId").value;
document
.getElementById("btnUpdateCustomer")
.addEventListener("click", async function () {
@@ -41,7 +42,7 @@ class UpdateCustomer {
result.message;
toast.show();
setTimeout(() => {
window.location.href = "/data/customers";
window.location.href = `/data/customers?menu_id=${menuId}`;
}, 2000);
} else {
let error = await response.json();

View File

@@ -32,6 +32,7 @@ class Customers {
tableContainer.innerHTML = "";
let canUpdate = tableContainer.getAttribute("data-updater") === "1";
let canDelete = tableContainer.getAttribute("data-destroyer") === "1";
let menuId = tableContainer.getAttribute("data-menuId");
this.table = new Grid({
columns: [
"ID",
@@ -45,15 +46,15 @@ class Customers {
name: "Action",
formatter: (cell) => {
let buttons = "";
if (canUpdate) {
buttons += `
<a href="/data/customers/${cell}/edit" class="btn btn-yellow btn-sm d-inline-flex align-items-center justify-content-center">
<a href="/data/customers/${cell}/edit?menu_id=${menuId}" class="btn btn-yellow btn-sm d-inline-flex align-items-center justify-content-center">
<i class='bx bx-edit'></i>
</a>
`;
}
if (canDelete) {
buttons += `
<button data-id="${cell}" class="btn btn-sm btn-red btn-delete-customers d-inline-flex align-items-center justify-content-center">
@@ -61,12 +62,14 @@ class Customers {
</button>
`;
}
if (!canUpdate && !canDelete) {
buttons = `<span class="text-muted">No Privilege</span>`;
}
return gridjs.html(`<div class="d-flex justify-content-center gap-2">${buttons}</div>`);
return gridjs.html(
`<div class="d-flex justify-content-center gap-2">${buttons}</div>`
);
},
},
],

View File

@@ -20,6 +20,7 @@ class UploadCustomers {
initDropzone() {
const toastNotification = document.getElementById("toastNotification");
const toast = new bootstrap.Toast(toastNotification);
let menuId = document.getElementById("menuId").value;
var previewTemplate,
dropzonePreviewNode = document.querySelector(
"#dropzone-preview-list"
@@ -46,7 +47,7 @@ class UploadCustomers {
response.message;
toast.show();
setTimeout(() => {
window.location.href = "/data/customers";
window.location.href = `/data/customers?menu_id=${menuId}`;
}, 2000);
});
this.on("error", function (file, errorMessage) {

View File

@@ -8,6 +8,7 @@ import GeneralTable from "../../table-generator.js";
const tableElement = document.getElementById("reklame-data-table");
const canUpdate = tableElement.getAttribute("data-updater") === "1";
const canDelete = tableElement.getAttribute("data-destroyer") === "1";
let menuId = document.getElementById("menuId").value;
const dataAdvertisementsColumns = [
"No",
@@ -23,13 +24,13 @@ const dataAdvertisementsColumns = [
{
name: "Actions",
width: "120px",
formatter: function(cell, row) {
formatter: function (cell, row) {
const id = row.cells[10].data;
const model = "data/advertisements";
const model = `data/web-advertisements`;
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;
@@ -40,7 +41,7 @@ const dataAdvertisementsColumns = [
<i class='bx bx-edit'></i>
</button>`;
}
// Tampilkan tombol Delete jika user punya akses delete
if (canDelete) {
hasPrivilege = true;
@@ -50,13 +51,17 @@ const dataAdvertisementsColumns = [
<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", () => {
@@ -86,4 +91,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;
@@ -73,7 +74,7 @@ document.addEventListener("DOMContentLoaded", function () {
}, 2000);
setTimeout(() => {
window.location.href = "/data/web-advertisements";
window.location.href = `/data/web-advertisements?menu_id=${menuId}`;
}, 1000);
} else {
if (authLogo) {