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();
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
@include('layouts.partials/page-title', ['title' => 'Data Settings', 'subtitle' => 'Setting Dashboard'])
|
||||
|
||||
<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 d-flex justify-content-end">
|
||||
<a href="{{ route('data-settings.index') }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
<a href="{{ route('data-settings.index', ['menu_id' => $menuId]) }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="formDataSettings" action="{{ route('api.data-settings.store') }}" method="POST">
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
@include('layouts.partials/page-title', ['title' => 'Data Settings', 'subtitle' => 'Setting Dashboard'])
|
||||
|
||||
<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 d-flex justify-content-end">
|
||||
<a href="{{ route('data-settings.index') }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
<a href="{{ route('data-settings.index', ['menu_id' => $menuId]) }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="formUpdateDataSettings" action="{{ route('api.data-settings.update', $data->id) }}" method="POST">
|
||||
|
||||
@@ -16,12 +16,13 @@
|
||||
<div class="card-body">
|
||||
<div class="d-flex flex-wrap justify-content-end align-items-center mb-2">
|
||||
@if ($creator)
|
||||
<a href="{{ route('data-settings.create')}}" class="btn btn-success btn-sm d-block d-sm-inline w-auto">Create</a>
|
||||
<a href="{{ route('data-settings.create', ['menu_id' => $menuId])}}" class="btn btn-success btn-sm d-block d-sm-inline w-auto">Create</a>
|
||||
@endif
|
||||
</div>
|
||||
<div id="table-data-settings"
|
||||
data-updater="{{ $updater }}"
|
||||
data-destroyer="{{ $destroyer }}">
|
||||
data-destroyer="{{ $destroyer }}"
|
||||
data-menuId="{{ $menuId }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user