fix redirect back data settings
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
document.addEventListener("DOMContentLoaded", function (e) {
|
||||
const toastNotification = document.getElementById("toastNotification");
|
||||
const toast = new bootstrap.Toast(toastNotification);
|
||||
let menuId = document.getElementById("menuId").value;
|
||||
document
|
||||
.getElementById("btnCreateDataSettings")
|
||||
.addEventListener("click", async function () {
|
||||
@@ -37,7 +38,7 @@ document.addEventListener("DOMContentLoaded", function (e) {
|
||||
result.data.message;
|
||||
toast.show();
|
||||
setTimeout(() => {
|
||||
window.location.href = "/data-settings";
|
||||
window.location.href = `/data-settings?menu_id=${menuId}`;
|
||||
}, 2000);
|
||||
} else {
|
||||
let error = await response.json();
|
||||
|
||||
@@ -32,7 +32,8 @@ class DataSettings {
|
||||
|
||||
tableContainer.innerHTML = "";
|
||||
let canUpdate = tableContainer.getAttribute("data-updater") === "1";
|
||||
let canDelete = tableContainer.getAttribute("data-destroyer") === "1"
|
||||
let canDelete = tableContainer.getAttribute("data-destroyer") === "1";
|
||||
let menuId = tableContainer.getAttribute("data-menuId");
|
||||
// Create a new Grid.js instance only if it doesn't exist
|
||||
this.table = new Grid({
|
||||
columns: [
|
||||
@@ -45,15 +46,15 @@ class DataSettings {
|
||||
width: "120px",
|
||||
formatter: function (cell) {
|
||||
let buttons = "";
|
||||
|
||||
|
||||
if (canUpdate) {
|
||||
buttons += `
|
||||
<a href="/data-settings/${cell}/edit" class="btn btn-yellow btn-sm d-inline-flex align-items-center justify-content-center">
|
||||
<a href="/data-settings/${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 class="btn btn-sm btn-red d-inline-flex align-items-center justify-content-center btn-delete-data-settings" data-id="${cell}">
|
||||
@@ -61,12 +62,14 @@ class DataSettings {
|
||||
</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>`
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@@ -6,6 +6,7 @@ document.addEventListener("DOMContentLoaded", function (e) {
|
||||
let toast = new bootstrap.Toast(
|
||||
document.getElementById("toastNotification")
|
||||
);
|
||||
let menuId = document.getElementById("menuId").value;
|
||||
submitButton.addEventListener("click", async function () {
|
||||
let submitButton = this;
|
||||
|
||||
@@ -36,7 +37,7 @@ document.addEventListener("DOMContentLoaded", function (e) {
|
||||
toastMessage.innerText = result.data.message;
|
||||
toast.show();
|
||||
setTimeout(() => {
|
||||
window.location.href = "/data-settings";
|
||||
window.location.href = `/data-settings?menu_id=${menuId}`;
|
||||
}, 2000);
|
||||
} else {
|
||||
let error = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user