Penambahan menu Perkuliahan
This commit is contained in:
@@ -3,9 +3,14 @@
|
||||
menurut flags katalog, centang, kolom, aksi baris, satu-foot), tetapi baris diambil server lewat satuRemoteTable
|
||||
(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.
|
||||
Tombol aksi hanya notifikasi prototipe.
|
||||
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.
|
||||
--}}
|
||||
@php
|
||||
$viewUrl ??= null;
|
||||
$destroyUrl ??= null;
|
||||
$destroy = ($destroy ?? []) + ['title' => 'Hapus data terpilih?', 'message' => 'Data yang dipilih akan dihapus.'];
|
||||
$tools = [
|
||||
'T' => ['Tambah', 'plus', 'primary', "demo('Tambah')"],
|
||||
'H' => ['Hapus', 'trash', 'danger', 'remove()'],
|
||||
@@ -26,26 +31,41 @@
|
||||
@php
|
||||
$config = [
|
||||
'url' => $url,
|
||||
'filters' => array_fill_keys(array_column($filters, 'name'), ''),
|
||||
'filters' => collect($filters)->mapWithKeys(fn (array $f): array => [$f['name'] => ($f['type'] ?? 'select') === 'check' ? false : (string) ($f['value'] ?? '')])->all(),
|
||||
'data' => $data,
|
||||
'viewUrl' => $viewUrl,
|
||||
'destroyUrl' => $destroyUrl,
|
||||
'token' => csrf_token(),
|
||||
];
|
||||
@endphp
|
||||
|
||||
<div class="stack" x-data="satuRemoteTable(@js($config))">
|
||||
@if ($filters)
|
||||
<x-glass.panel padding="sm" as="section" aria-label="Filter data">
|
||||
<div class="filter-bar">
|
||||
@foreach ($filters as $filter)
|
||||
<x-form.select
|
||||
:name="'filter_'.$filter['name']"
|
||||
:label="$filter['label']"
|
||||
:options="$filter['options']"
|
||||
placeholder=""
|
||||
x-model="values.{{ $filter['name'] }}"
|
||||
x-on:change="search()"
|
||||
/>
|
||||
@if (($filter['type'] ?? 'select') === 'check')
|
||||
<x-form.checkbox
|
||||
:name="'filter_'.$filter['name']"
|
||||
:label="$filter['label']"
|
||||
x-model="values.{{ $filter['name'] }}"
|
||||
x-on:change="search()"
|
||||
/>
|
||||
@else
|
||||
<x-form.select
|
||||
:name="'filter_'.$filter['name']"
|
||||
:label="$filter['label']"
|
||||
:options="$filter['options']"
|
||||
:value="$filter['value'] ?? null"
|
||||
placeholder=""
|
||||
x-model="values.{{ $filter['name'] }}"
|
||||
x-on:change="search()"
|
||||
/>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
@endif
|
||||
|
||||
<x-glass.panel padding="none" as="section" :aria-label="'Daftar '.$page['title']">
|
||||
<div class="satu-bar">
|
||||
@@ -94,9 +114,17 @@
|
||||
@endforeach
|
||||
@if ($actions)
|
||||
<td class="table__actions">
|
||||
<x-ui.button variant="ghost" size="sm" icon="eye" :icon-only="true" aria-label="Lihat" x-on:click="demo('Lihat')" />
|
||||
@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
|
||||
<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')" />
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="demo('Hapus')" />
|
||||
@if ($destroyUrl)
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="askRemove([row.id])" />
|
||||
@else
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="demo('Hapus')" />
|
||||
@endif
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
@@ -127,6 +155,22 @@
|
||||
</nav>
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
@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">
|
||||
<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>
|
||||
</div>
|
||||
<p id="satu-hapus-pesan" class="dialog__message"><span x-text="pending.length"></span> baris dipilih. {{ $destroy['message'] }}</p>
|
||||
<div class="dialog__actions">
|
||||
<x-ui.button variant="danger" x-on:click="confirmRemove()" x-bind:disabled="loading">Ya, hapus</x-ui.button>
|
||||
<x-ui.button variant="secondary" x-on:click="closeDialog()">Batal</x-ui.button>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
</x-satu.frame>
|
||||
|
||||
Reference in New Issue
Block a user