fix redirect back users crud

This commit is contained in:
arifal
2025-03-12 21:17:49 +07:00
parent 7a82ad5302
commit 4db457d7bd
7 changed files with 30 additions and 36 deletions

View File

@@ -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("btnCreateUsers")
.addEventListener("click", async function () {
@@ -45,7 +46,7 @@ document.addEventListener("DOMContentLoaded", function (e) {
result.message;
toast.show();
setTimeout(() => {
window.location.href = "/master/users";
window.location.href = `/master/users?menu_id=${menuId}`;
}, 2000);
} else {
let error = await response.json();

View File

@@ -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.message;
toast.show();
setTimeout(() => {
window.location.href = "/master/users";
window.location.href = `/master/users?menu_id=${menuId}`;
}, 2000);
} else {
let error = await response.json();

View File

@@ -9,9 +9,8 @@ class UsersTable {
}
initTableUsers() {
let tableContainer = document.getElementById(
"table-users"
);
let tableContainer = document.getElementById("table-users");
let menuId = tableContainer.getAttribute("data-menuId");
tableContainer.innerHTML = "";
let canUpdate = tableContainer.getAttribute("data-updater") === "1";
@@ -26,13 +25,15 @@ class UsersTable {
"Roles",
{
name: "Action",
formatter: (cell) =>{
formatter: (cell) => {
if (!canUpdate) {
return gridjs.html(`<span class="text-muted">No Privilege</span>`);
return gridjs.html(
`<span class="text-muted">No Privilege</span>`
);
}
return gridjs.html(`
<div class="d-flex justify-content-center">
<a href="/master/users/${cell}/edit" class="btn btn-yellow btn-sm d-inline-flex align-items-center justify-content-center">
<a href="/master/users/${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>
</div>