Integrasi Menu Laporan Operator
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
(fetch JSON ke $url), sehingga alamat halaman tidak berubah. Halaman pertama ikut dirender sebagai data awal.
|
||||
columns: [['key', 'label', 'num' => bool, 'badge' => bool]]; kolom badge memakai row.{key} dan nada row.tone.
|
||||
filters: [['name', 'label', 'options' => [], 'value' => bawaan]] atau ['name', 'label', 'type' => 'check'].
|
||||
$strict (bawaan false): true = hanya tombol yang sungguh bekerja (tanpa tombol notifikasi prototipe).
|
||||
Opsional: $viewUrl (aksi Lihat, "__ID__" diganti row.id), $destroyUrl + $destroy['title'|'message'] (Hapus sungguhan
|
||||
lewat POST {ids}); $form = ['title', 'storeUrl', 'updateUrl' ("__ID__"), 'fields' => [['name', 'label', 'type' =>
|
||||
text|number|date|select, 'options', 'required', 'max', 'min', 'hint', 'multiple', 'default']]] untuk Tambah/Ubah lewat
|
||||
@@ -13,6 +14,7 @@
|
||||
$viewUrl ??= null;
|
||||
$destroyUrl ??= null;
|
||||
$form ??= null;
|
||||
$strict ??= false;
|
||||
$destroy = ($destroy ?? []) + ['title' => 'Hapus data terpilih?', 'message' => 'Data yang dipilih akan dihapus.'];
|
||||
$tools = [
|
||||
'T' => ['Tambah', 'plus', 'primary', $form ? 'startInsert()' : "demo('Tambah')"],
|
||||
@@ -20,7 +22,8 @@
|
||||
'A' => ['Aksi', 'ellipsis-horizontal-circle', 'secondary', "demo('Aksi')"],
|
||||
'C' => ['Cetak', 'printer', 'secondary', 'window.print()'],
|
||||
];
|
||||
$active = array_filter($tools, fn (string $key): bool => str_contains($page['flags'], $key), ARRAY_FILTER_USE_KEY);
|
||||
$active = array_filter($tools, fn (string $key): bool => str_contains($page['flags'], $key)
|
||||
&& (! $strict || match ($key) { 'T' => (bool) $form, 'H' => (bool) $destroyUrl, 'A' => false, default => true }), ARRAY_FILTER_USE_KEY);
|
||||
$checkbox = in_array('#', $page['columns'], true);
|
||||
$actions = in_array('Aksi', $page['columns'], true);
|
||||
@endphp
|
||||
@@ -120,17 +123,17 @@
|
||||
<td class="table__actions">
|
||||
@if ($viewUrl)
|
||||
<a class="btn btn--ghost btn--sm btn--icon" x-bind:href="link(row)" aria-label="Lihat"><x-heroicon-o-eye /></a>
|
||||
@else
|
||||
@elseif (! $strict)
|
||||
<x-ui.button variant="ghost" size="sm" icon="eye" :icon-only="true" aria-label="Lihat" x-on:click="demo('Lihat')" />
|
||||
@endif
|
||||
@if ($form)
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="startEdit(row)" />
|
||||
@else
|
||||
@elseif (! $strict)
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="demo('Ubah')" />
|
||||
@endif
|
||||
@if ($destroyUrl)
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="askRemove([row.id])" />
|
||||
@else
|
||||
@elseif (! $strict)
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="demo('Hapus')" />
|
||||
@endif
|
||||
</td>
|
||||
@@ -166,11 +169,12 @@
|
||||
|
||||
@if ($form)
|
||||
{{-- Modal formulir tambah/ubah: kolom menurut $form['fields'], nilai di formData --}}
|
||||
<dialog x-ref="form" class="dialog dialog--wide" aria-labelledby="satu-form-judul" x-on:click="formBackdrop($event)" x-on:close="editing = null">
|
||||
<dialog x-ref="form" class="dialog dialog--wide" aria-labelledby="satu-form-judul" x-on:click="formBackdrop($event)" x-on:close="setTimeout(() => $refs.form.open || (editing = null), 300)">
|
||||
<form class="dialog__body" x-on:submit.prevent="save()" novalidate>
|
||||
<div class="dialog__head">
|
||||
<span class="dialog__icon" aria-hidden="true"><x-heroicon-o-pencil-square /></span>
|
||||
<p id="satu-form-judul" class="dialog__title" x-text="editing === 'new' ? 'Tambah {{ $form['title'] }}' : 'Ubah {{ $form['title'] }}'"></p>
|
||||
<x-ui.dialog-close />
|
||||
</div>
|
||||
|
||||
<div class="satu-form">
|
||||
@@ -194,7 +198,7 @@
|
||||
:type="$f['type'] ?? 'text'"
|
||||
:optional="! ($f['required'] ?? false)"
|
||||
:hint="$f['hint'] ?? null"
|
||||
:placeholder="$f['placeholder'] ?? null"
|
||||
:placeholder="$f['placeholder'] ?? (in_array($f['type'] ?? 'text', ['text', 'number'], true) ? 'Masukkan '.ucwords($f['label']) : null)"
|
||||
:required="$f['required'] ?? false"
|
||||
:maxlength="($f['type'] ?? 'text') === 'text' ? ($f['max'] ?? null) : null"
|
||||
:min="($f['type'] ?? 'text') === 'number' ? ($f['min'] ?? null) : null"
|
||||
@@ -214,11 +218,12 @@
|
||||
@endif
|
||||
|
||||
@if ($destroyUrl)
|
||||
<dialog x-ref="dialog" class="dialog dialog--danger" aria-labelledby="satu-hapus-judul" aria-describedby="satu-hapus-pesan" x-on:click="backdrop($event)" x-on:close="pending = []">
|
||||
<dialog x-ref="dialog" class="dialog dialog--danger" aria-labelledby="satu-hapus-judul" aria-describedby="satu-hapus-pesan" x-on:click="backdrop($event)" x-on:close="setTimeout(() => $refs.dialog.open || (pending = []), 300)">
|
||||
<div class="dialog__body">
|
||||
<div class="dialog__head">
|
||||
<span class="dialog__icon" aria-hidden="true"><x-heroicon-o-exclamation-triangle /></span>
|
||||
<p id="satu-hapus-judul" class="dialog__title">{{ $destroy['title'] }}</p>
|
||||
<x-ui.dialog-close />
|
||||
</div>
|
||||
<p id="satu-hapus-pesan" class="dialog__message"><span x-text="pending.length"></span> baris dipilih. {{ $destroy['message'] }}</p>
|
||||
<div class="dialog__actions">
|
||||
|
||||
Reference in New Issue
Block a user