Perbaikan menu Operator
This commit is contained in:
@@ -5,14 +5,17 @@
|
||||
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'].
|
||||
Opsional: $viewUrl (aksi Lihat, "__ID__" diganti row.id), $destroyUrl + $destroy['title'|'message'] (Hapus sungguhan
|
||||
lewat POST {ids}); tanpa keduanya tombol aksi hanya notifikasi prototipe.
|
||||
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
|
||||
modal (baris data menyediakan row.form = nilai isian). Tanpa semuanya tombol aksi hanya notifikasi prototipe.
|
||||
--}}
|
||||
@php
|
||||
$viewUrl ??= null;
|
||||
$destroyUrl ??= null;
|
||||
$form ??= null;
|
||||
$destroy = ($destroy ?? []) + ['title' => 'Hapus data terpilih?', 'message' => 'Data yang dipilih akan dihapus.'];
|
||||
$tools = [
|
||||
'T' => ['Tambah', 'plus', 'primary', "demo('Tambah')"],
|
||||
'T' => ['Tambah', 'plus', 'primary', $form ? 'startInsert()' : "demo('Tambah')"],
|
||||
'H' => ['Hapus', 'trash', 'danger', 'remove()'],
|
||||
'A' => ['Aksi', 'ellipsis-horizontal-circle', 'secondary', "demo('Aksi')"],
|
||||
'C' => ['Cetak', 'printer', 'secondary', 'window.print()'],
|
||||
@@ -35,6 +38,7 @@
|
||||
'data' => $data,
|
||||
'viewUrl' => $viewUrl,
|
||||
'destroyUrl' => $destroyUrl,
|
||||
'form' => $form ? ['storeUrl' => $form['storeUrl'], 'updateUrl' => $form['updateUrl'], 'fields' => array_map(fn (array $f): array => ['name' => $f['name'], 'default' => $f['default'] ?? (($f['multiple'] ?? false) ? [] : '')], $form['fields'])] : null,
|
||||
'token' => csrf_token(),
|
||||
];
|
||||
@endphp
|
||||
@@ -119,7 +123,11 @@
|
||||
@else
|
||||
<x-ui.button variant="ghost" size="sm" icon="eye" :icon-only="true" aria-label="Lihat" x-on:click="demo('Lihat')" />
|
||||
@endif
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="demo('Ubah')" />
|
||||
@if ($form)
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="startEdit(row)" />
|
||||
@else
|
||||
<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
|
||||
@@ -156,6 +164,55 @@
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
@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">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<div class="satu-form">
|
||||
@foreach ($form['fields'] as $f)
|
||||
@if (($f['type'] ?? 'text') === 'select')
|
||||
<x-form.select
|
||||
:name="'form_'.$f['name']"
|
||||
:label="$f['label']"
|
||||
:options="$f['options']"
|
||||
:optional="! ($f['required'] ?? false)"
|
||||
:hint="$f['hint'] ?? null"
|
||||
placeholder=""
|
||||
:required="$f['required'] ?? false"
|
||||
:multiple="$f['multiple'] ?? false"
|
||||
x-model="formData.{{ $f['name'] }}"
|
||||
/>
|
||||
@else
|
||||
<x-form.field
|
||||
:name="'form_'.$f['name']"
|
||||
:label="$f['label']"
|
||||
:type="$f['type'] ?? 'text'"
|
||||
:optional="! ($f['required'] ?? false)"
|
||||
:hint="$f['hint'] ?? null"
|
||||
:placeholder="$f['placeholder'] ?? null"
|
||||
:required="$f['required'] ?? false"
|
||||
:maxlength="($f['type'] ?? 'text') === 'text' ? ($f['max'] ?? null) : null"
|
||||
:min="($f['type'] ?? 'text') === 'number' ? ($f['min'] ?? null) : null"
|
||||
:max="($f['type'] ?? 'text') === 'number' ? ($f['max'] ?? null) : null"
|
||||
x-model="formData.{{ $f['name'] }}"
|
||||
/>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="dialog__actions">
|
||||
<x-ui.button type="submit" variant="primary" icon="check" x-bind:disabled="loading">Simpan</x-ui.button>
|
||||
<x-ui.button variant="secondary" x-on:click="closeForm()">Batal</x-ui.button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
@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 = []">
|
||||
<div class="dialog__body">
|
||||
|
||||
Reference in New Issue
Block a user