Pembaruan halaman Operator dan Mahasiswa
This commit is contained in:
@@ -549,6 +549,8 @@ a.stat { text-decoration: none; color: inherit; }
|
||||
align-items: start;
|
||||
}
|
||||
.satu-form__check { align-self: center; }
|
||||
.satu-detail dt { font-size: var(--text-sm); font-weight: 600; color: var(--color-muted); }
|
||||
.satu-detail dd { margin: 0; overflow-wrap: anywhere; }
|
||||
.satu-form__actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-sm); }
|
||||
|
||||
.satu-dl { display: grid; gap: 0; margin: 0; }
|
||||
|
||||
@@ -800,6 +800,14 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
form: config.form ?? null,
|
||||
editing: null,
|
||||
formData: {},
|
||||
// Modal Lihat: kolom tabel dan baris yang sedang dilihat
|
||||
columns: config.columns ?? [],
|
||||
viewing: null,
|
||||
|
||||
startView(row) {
|
||||
this.viewing = row;
|
||||
this.$refs.detail?.showModal();
|
||||
},
|
||||
|
||||
get window() {
|
||||
const start = Math.max(1, Math.min(this.page - 2, this.pages - 4));
|
||||
|
||||
@@ -4,26 +4,24 @@
|
||||
(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
|
||||
modal (baris data menyediakan row.form = nilai isian). Tanpa semuanya tombol aksi hanya notifikasi prototipe.
|
||||
modal (baris data menyediakan row.form = nilai isian). Hanya tombol yang sungguh bekerja yang ditampilkan; Lihat tanpa
|
||||
$viewUrl membuka modal detail seluruh kolom baris.
|
||||
--}}
|
||||
@php
|
||||
$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')"],
|
||||
'T' => ['Tambah', 'plus', 'primary', 'startInsert()'],
|
||||
'H' => ['Hapus', 'trash', 'danger', 'remove()'],
|
||||
'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)
|
||||
&& (! $strict || match ($key) { 'T' => (bool) $form, 'H' => (bool) $destroyUrl, 'A' => false, default => true }), ARRAY_FILTER_USE_KEY);
|
||||
&& match ($key) { 'T' => (bool) $form, 'H' => (bool) $destroyUrl, default => true }, ARRAY_FILTER_USE_KEY);
|
||||
$checkbox = in_array('#', $page['columns'], true);
|
||||
$actions = in_array('Aksi', $page['columns'], true);
|
||||
@endphp
|
||||
@@ -42,6 +40,7 @@
|
||||
'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,
|
||||
'columns' => collect($columns)->map(fn (array $c): array => ['key' => $c['key'], 'label' => $c['label']])->values()->all(),
|
||||
'token' => csrf_token(),
|
||||
];
|
||||
@endphp
|
||||
@@ -123,18 +122,16 @@
|
||||
<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>
|
||||
@elseif (! $strict)
|
||||
<x-ui.button variant="ghost" size="sm" icon="eye" :icon-only="true" aria-label="Lihat" x-on:click="demo('Lihat')" />
|
||||
@else
|
||||
<x-ui.button variant="ghost" size="sm" icon="eye" :icon-only="true" aria-label="Lihat" x-on:click="startView(row)" />
|
||||
@endif
|
||||
@if ($form)
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="startEdit(row)" />
|
||||
@elseif (! $strict)
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="demo('Ubah')" />
|
||||
<template x-if="row.form">
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="startEdit(row)" />
|
||||
</template>
|
||||
@endif
|
||||
@if ($destroyUrl)
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="askRemove([row.id])" />
|
||||
@elseif (! $strict)
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="demo('Hapus')" />
|
||||
@endif
|
||||
</td>
|
||||
@endif
|
||||
@@ -167,6 +164,30 @@
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
@if ($actions && ! $viewUrl)
|
||||
{{-- Modal Lihat: seluruh kolom baris terpilih, hanya baca --}}
|
||||
<dialog x-ref="detail" class="dialog dialog--wide" aria-labelledby="satu-detail-judul" x-on:click="if ($event.target === $refs.detail) $refs.detail.close()">
|
||||
<div class="dialog__body">
|
||||
<div class="dialog__head">
|
||||
<span class="dialog__icon" aria-hidden="true"><x-heroicon-o-eye /></span>
|
||||
<p id="satu-detail-judul" class="dialog__title">Detail {{ Str::lower($page['title']) }}</p>
|
||||
<x-ui.dialog-close />
|
||||
</div>
|
||||
<dl class="satu-form satu-detail">
|
||||
<template x-for="col in columns" x-bind:key="col.key">
|
||||
<div>
|
||||
<dt x-text="col.label"></dt>
|
||||
<dd x-text="viewing && viewing[col.key] !== null && viewing[col.key] !== '' && viewing[col.key] !== undefined ? viewing[col.key] : '-'"></dd>
|
||||
</div>
|
||||
</template>
|
||||
</dl>
|
||||
<div class="dialog__actions">
|
||||
<x-ui.button variant="secondary" x-on:click="$refs.detail.close()">Tutup</x-ui.button>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
@endif
|
||||
|
||||
@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="setTimeout(() => $refs.form.open || (editing = null), 300)">
|
||||
|
||||
Reference in New Issue
Block a user