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>

View File

@@ -5,12 +5,13 @@
@include('layouts.partials/page-title', ['title' => 'Users', 'subtitle' => 'Create'])
<x-toast-notification />
<input type="hidden" id="menuId" value="{{ $menuId ?? 0 }}">
<div class="row d-flex justify-content-center">
<div class="col-lg-6">
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-end">
<a href="{{ route('users.index') }}" class="btn btn-sm btn-secondary me-2">Back</a>
<a href="{{ route('users.index', ['menu_id' => $menuId]) }}" class="btn btn-sm btn-secondary me-2">Back</a>
</div>
</div>
<div class="card-body">

View File

@@ -5,12 +5,13 @@
@include('layouts.partials/page-title', ['title' => 'Users', 'subtitle' => 'Create'])
<x-toast-notification />
<input type="hidden" id="menuId" value="{{ $menuId ?? 0 }}">
<div class="row d-flex justify-content-center">
<div class="col-lg-6">
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-end">
<a href="{{ route('users.index') }}" class="btn btn-sm btn-secondary me-2">Back</a>
<a href="{{ route('users.index', ['menu_id' => $menuId]) }}" class="btn btn-sm btn-secondary me-2">Back</a>
</div>
</div>
<div class="card-body">

View File

@@ -14,14 +14,15 @@
<div class="card-body">
<div class="d-flex flex-wrap justify-content-end align-items-center mb-2">
@if ($creator)
<a href="{{ route('users.create') }}" class="btn btn-success btn-sm d-block d-sm-inline w-auto">
<a href="{{ route('users.create', ['menu_id' => $menuId]) }}" class="btn btn-success btn-sm d-block d-sm-inline w-auto">
Create
</a>
@endif
</div>
<div id="table-users"
data-updater="{{ $updater }}"
data-destroyer="{{ $destroyer }}">
data-destroyer="{{ $destroyer }}"
data-menuId="{{ $menuId }}">
</div>
</div>
</div>