fix conflict

This commit is contained in:
arifal
2025-03-07 14:52:51 +07:00
40 changed files with 817 additions and 220 deletions

View File

@@ -28,35 +28,9 @@ class Menus {
initTableMenus() {
let tableContainer = document.getElementById("table-menus");
// if (this.table) {
// // If table exists, update its data instead of recreating
// this.table
// .updateConfig({
// server: {
// url: `${GlobalConfig.apiHost}/api/menus`,
// credentials: "include",
// headers: {
// Authorization: `Bearer ${document
// .querySelector('meta[name="api-token"]')
// .getAttribute("content")}`,
// "Content-Type": "application/json",
// },
// then: (data) =>
// data.data.map((item) => [
// item.id,
// item.name,
// item.url,
// item.icon,
// item.parent_id,
// item.sort_order,
// item.id,
// ]),
// total: (data) => data.total,
// },
// })
// .forceRender();
// return;
// }
tableContainer.innerHTML = "";
let canUpdate = tableContainer.getAttribute("data-updater") === "1";
let canDelete = tableContainer.getAttribute("data-destroyer") === "1";
this.table = new Grid({
columns: [
@@ -68,18 +42,33 @@ class Menus {
"Sort Order",
{
name: "Action",
formatter: (cell) =>
gridjs.html(`
<div class="d-flex justify-content-center align-items-center gap-2">
<a href="/menus/${cell}/edit" class="btn btn-yellow btn-sm d-inline-flex align-items-center justify-content-center">
<i class='bx bx-edit'></i>
</a>
<button data-id="${cell}"
class="btn btn-red btn-sm btn-delete-menu d-inline-flex align-items-center justify-content-center">
<i class='bx bxs-trash' ></i>
</button>
</div>
`),
formatter: (cell) => {
let buttons = `<div class="d-flex justify-content-center align-items-center gap-2">`;
if (canUpdate) {
buttons += `
<a href="/menus/${cell}/edit" 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 data-id="${cell}" class="btn btn-red btn-sm btn-delete-menu 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>`;
}
buttons += `</div>`;
return gridjs.html(buttons);
},
},
],
pagination: {