fix redirect back with params menu id

This commit is contained in:
arifal
2025-03-12 17:52:11 +07:00
parent 68ffc1c090
commit b0d4d4c23b
7 changed files with 52 additions and 34 deletions

View File

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

View File

@@ -31,6 +31,7 @@ class Menus {
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: [
@@ -47,7 +48,7 @@ class Menus {
if (canUpdate) {
buttons += `
<a href="/menus/${cell}/edit" class="btn btn-yellow btn-sm d-inline-flex align-items-center justify-content-center">
<a href="/menus/${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>
`;

View File

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

View File

@@ -5,11 +5,12 @@
@include('layouts.partials/page-title', ['title' => 'Settings', 'subtitle' => 'Menu'])
<x-toast-notification />
<input type="hidden" id="menuId" value="{{ $menuId ?? 0 }}">
<div class="row d-flex justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header d-flex justify-content-end">
<a href="{{ route('menus.index') }}" class="btn btn-sm btn-secondary">Back</a>
<a href="{{ route('menus.index', ['menu_id' => $menuId ?? 0]) }}" class="btn btn-sm btn-secondary">Back</a>
</div>
<div class="card-body">
<form id="formCreateMenus" action="{{route("api.menus.store")}}" method="post">

View File

@@ -9,11 +9,12 @@
@include('layouts.partials/page-title', ['title' => 'Settings', 'subtitle' => 'Menu'])
<x-toast-notification/>
<input type="hidden" id="menuId" value="{{ $menuId ?? 0 }}">
<div class="row d-flex justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header d-flex justify-content-end">
<a href="{{ route('menus.index') }}" class="btn btn-sm btn-secondary">Back</a>
<a href="{{ route('menus.index', ['menu_id' => $menuId]) }}" class="btn btn-sm btn-secondary">Back</a>
</div>
<div class="card-body">
<form id="formUpdateMenus" action="{{route("api.menus.update", $menu->id)}}" method="post">

View File

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