fix redirect back roles
This commit is contained in:
@@ -6,6 +6,7 @@ class CreateRoles {
|
||||
initCreateRole() {
|
||||
const toastNotification = document.getElementById("toastNotification");
|
||||
const toast = new bootstrap.Toast(toastNotification);
|
||||
let menuId = document.getElementById("menuId").value;
|
||||
document
|
||||
.getElementById("btnCreateRole")
|
||||
.addEventListener("click", async function () {
|
||||
@@ -41,7 +42,7 @@ class CreateRoles {
|
||||
result.message;
|
||||
toast.show();
|
||||
setTimeout(() => {
|
||||
window.location.href = "/roles";
|
||||
window.location.href = `/roles?menu_id=${menuId}`;
|
||||
}, 2000);
|
||||
} else {
|
||||
let error = await response.json();
|
||||
|
||||
@@ -31,6 +31,7 @@ class Roles {
|
||||
tableContainer.innerHTML = "";
|
||||
let canUpdate = tableContainer.getAttribute("data-updater") === "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 gridjs.Grid({
|
||||
columns: [
|
||||
@@ -38,38 +39,38 @@ class Roles {
|
||||
"Name",
|
||||
"Description",
|
||||
{
|
||||
name: "Action",
|
||||
formatter: (cell) => {
|
||||
let buttons = `<div class="d-flex justify-content-center gap-2">`;
|
||||
name: "Action",
|
||||
formatter: (cell) => {
|
||||
let buttons = `<div class="d-flex justify-content-center gap-2">`;
|
||||
|
||||
if (canUpdate) {
|
||||
buttons += `
|
||||
<a href="/roles/${cell}/edit" class="btn btn-yellow btn-sm d-inline-flex align-items-center justify-content-center">
|
||||
if (canUpdate) {
|
||||
buttons += `
|
||||
<a href="/roles/${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>
|
||||
<a href="/roles/role-menu/${cell}" class="btn btn-primary btn-sm d-inline-flex align-items-center justify-content-center">
|
||||
<a href="/roles/role-menu/${cell}?menu_id=${menuId}" class="btn btn-primary btn-sm d-inline-flex align-items-center justify-content-center">
|
||||
Role Menu
|
||||
</a>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
if (canDelete) {
|
||||
buttons += `
|
||||
if (canDelete) {
|
||||
buttons += `
|
||||
<button data-id="${cell}" class="btn btn-sm btn-red btn-delete-role d-inline-flex align-items-center justify-content-center">
|
||||
<i class='bx bxs-trash'></i>
|
||||
</button>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
if (!canUpdate && !canDelete) {
|
||||
buttons += `<span class="text-muted">No Privilege</span>`;
|
||||
}
|
||||
if (!canUpdate && !canDelete) {
|
||||
buttons += `<span class="text-muted">No Privilege</span>`;
|
||||
}
|
||||
|
||||
buttons += `</div>`;
|
||||
buttons += `</div>`;
|
||||
|
||||
return gridjs.html(buttons);
|
||||
return gridjs.html(buttons);
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
pagination: {
|
||||
limit: 50,
|
||||
|
||||
@@ -6,6 +6,7 @@ class UpdateRoles {
|
||||
initUpdateRole() {
|
||||
const toastNotification = document.getElementById("toastNotification");
|
||||
const toast = new bootstrap.Toast(toastNotification);
|
||||
let menuId = document.getElementById("menuId").value;
|
||||
document
|
||||
.getElementById("btnUpdateRole")
|
||||
.addEventListener("click", async function () {
|
||||
@@ -41,7 +42,7 @@ class UpdateRoles {
|
||||
result.message;
|
||||
toast.show();
|
||||
setTimeout(() => {
|
||||
window.location.href = "/roles";
|
||||
window.location.href = `/roles?menu_id=${menuId}`;
|
||||
}, 2000);
|
||||
} else {
|
||||
let error = await response.json();
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
@include('layouts.partials/page-title', ['title' => 'Settings', 'subtitle' => 'Menu'])
|
||||
|
||||
<x-toast-notification />
|
||||
<x-modal-confirmation buttonText="Delete" confirmationMessage="Are you sure you want to delete this?" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
@include('layouts.partials/page-title', ['title' => 'Settings', 'subtitle' => 'Role'])
|
||||
|
||||
<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('roles.index') }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
<a href="{{ route('roles.index', ['menu_id' => $menuId]) }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{route("api.roles.store")}}" method="post" id="formCreateRole" data-redirect="{{route("roles.index")}}">
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
@include('layouts.partials/page-title', ['title' => 'Settings', 'subtitle' => 'Role'])
|
||||
|
||||
<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('roles.index') }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
<a href="{{ route('roles.index', ['menu_id' => $menuId]) }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="formUpdateRole" action="{{route("api.roles.update", $role->id)}}" method="post" >
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
@include('layouts.partials/page-title', ['title' => 'Settings', 'subtitle' => 'Role'])
|
||||
|
||||
<x-toast-notification/>
|
||||
<x-modal-confirmation buttonText="Delete" confirmationMessage="Are you sure you want to delete this?" />
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@@ -17,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('roles.create')}}" class="btn btn-success btn-sm d-block d-sm-inline w-auto">Create</a>
|
||||
<a href="{{ route('roles.create', ['menu_id' => $menuId])}}" class="btn btn-success btn-sm d-block d-sm-inline w-auto">Create</a>
|
||||
@endif
|
||||
</div>
|
||||
<div id="table-roles"
|
||||
data-updater="{{ $updater }}"
|
||||
data-destroyer="{{ $destroyer }}">
|
||||
data-destroyer="{{ $destroyer }}"
|
||||
data-menuId="{{ $menuId }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-header d-flex justify-content-end">
|
||||
<a href="{{ route('roles.index') }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
<a href="{{ route('roles.index', ['menu_id' => $menuId]) }}" class="btn btn-sm btn-secondary">Back</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5>Manage Permissions for Role: {{ $role->name }}</h5>
|
||||
<form action="{{route("role-menu.permission.update", $role->id)}}" method="post">
|
||||
<form action="{{ route('role-menu.permission.update', ['role_id' => $role->id]) }}?menu_id={{ $menuId }}" method="post">
|
||||
@csrf
|
||||
@method("put")
|
||||
<table class="table">
|
||||
|
||||
Reference in New Issue
Block a user