[Operator] Perbaikan Laman Kegiatan

This commit is contained in:
Ariyutta
2026-11-11 11:20:49 +07:00
parent f9ad783162
commit eba6ab77b4
15 changed files with 906 additions and 214 deletions
@@ -6,8 +6,13 @@
filters: [['name', 'label', 'options' => [], 'value' => bawaan]] atau ['name', 'label', 'type' => 'check'].
Opsional: $tools (kunci tombol bilah yang boleh tampil, [] = tanpa tombol), $selectable (false = tanpa kotak centang),
$editable (false = tanpa aksi Ubah di baris; $form hanya untuk Tambah),
$viewable (false = tanpa aksi Lihat dan modal detail di baris),
kolom 'swatch' => true (kotak warna + kode dari row.{key}), isian form type 'color' (pemilih warna + kode heksa), dan
isian 'wide' => true (selebar penuh baris), select 'tags' => true (daftar yang bisa dicari sekaligus boleh membuat nilai baru dengan mengetik; nilai = teks) serta
'placeholder' (teks placeholder select),
$ownRowsOnly (true = kotak centang dan Hapus per baris hanya pada baris yang membawa row.form; baris lain hanya dibaca),
$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' =>
lewat POST {ids}); $form = ['title', 'withFilters' (opsional: nama filter yang nilainya ikut dikirim saat simpan), '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). Hanya tombol yang sungguh bekerja yang ditampilkan; Lihat tanpa
$viewUrl membuka modal detail seluruh kolom baris.
@@ -18,6 +23,8 @@
$form ??= null;
$selectable ??= true;
$editable ??= true;
$ownRowsOnly ??= false;
$viewable ??= true;
$destroy = ($destroy ?? []) + ['title' => 'Hapus data terpilih?', 'message' => 'Data yang dipilih akan dihapus.'];
$allTools = [
'T' => ['Tambah', 'plus', 'primary', 'startInsert()'],
@@ -43,9 +50,10 @@
'url' => $url,
'filters' => collect($filters)->mapWithKeys(fn (array $f): array => [$f['name'] => ($f['type'] ?? 'select') === 'check' ? false : (string) ($f['value'] ?? '')])->all(),
'data' => $data,
'ownRowsOnly' => $ownRowsOnly,
'viewUrl' => $viewUrl,
'destroyUrl' => $destroyUrl,
'form' => $form ? ['storeUrl' => $form['storeUrl'], 'updateUrl' => $form['updateUrl'] ?? null, 'fields' => array_map(fn (array $f): array => ['name' => $f['name'], 'default' => $f['default'] ?? (($f['multiple'] ?? false) ? [] : '')], $form['fields'])] : null,
'form' => $form ? ['withFilters' => $form['withFilters'] ?? [], 'storeUrl' => $form['storeUrl'], 'updateUrl' => $form['updateUrl'] ?? null, '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(),
];
@@ -115,11 +123,20 @@
<template x-for="row in view" x-bind:key="row.id">
<tr>
@if ($checkbox)
<td class="satu-check"><input type="checkbox" class="check__input" aria-label="Pilih baris" x-model="picked" x-bind:value="row.id"></td>
<td class="satu-check">
@if ($ownRowsOnly)
<template x-if="row.form"><input type="checkbox" class="check__input" aria-label="Pilih baris" x-model="picked" x-bind:value="row.id"></template>
@else
<input type="checkbox" class="check__input" aria-label="Pilih baris" x-model="picked" x-bind:value="row.id">
@endif
</td>
@endif
@foreach ($columns as $column)
@if ($column['badge'] ?? false)
<td><span class="badge" x-bind:class="row.tone ? 'badge--' + row.tone : ''" x-text="row.{{ $column['key'] }}"></span></td>
@elseif ($column['swatch'] ?? false)
{{-- Kotak warna dari data (row.{key} = "#RRGGBB" atau null) + kode warnanya --}}
<td><span class="swatch"><i class="swatch__chip" aria-hidden="true" x-bind:style="row.{{ $column['key'] }} ? '--swatch: ' + row.{{ $column['key'] }} : ''"></i><span x-text="row.{{ $column['key'] }} ?? '–'"></span></span></td>
@else
<td @class(['num' => $column['num'] ?? false, 'table__title' => $loop->first && ! $checkbox])><span x-text="row.{{ $column['key'] }}"></span></td>
@endif
@@ -128,7 +145,7 @@
<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 ($viewable)
<x-ui.button variant="ghost" size="sm" icon="eye" :icon-only="true" aria-label="Lihat" x-on:click="startView(row)" />
@endif
@if ($form && $editable)
@@ -137,8 +154,12 @@
</template>
@endif
@if ($destroyUrl)
@if ($ownRowsOnly)
<template x-if="row.form"><x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="askRemove([row.id])" /></template>
@else
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="askRemove([row.id])" />
@endif
@endif
</td>
@endif
</tr>
@@ -170,7 +191,7 @@
</div>
</x-glass.panel>
@if ($actions && ! $viewUrl)
@if ($actions && ! $viewUrl && $viewable)
{{-- 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">
@@ -206,6 +227,8 @@
<div class="satu-form">
@foreach ($form['fields'] as $f)
{{-- 'wide' => true: isian selebar penuh baris --}}
@if ($f['wide'] ?? false) <div class="col-span-full"> @endif
@if (($f['type'] ?? 'text') === 'select')
<x-form.select
:name="'form_'.$f['name']"
@@ -216,8 +239,19 @@
placeholder=""
:required="$f['required'] ?? false"
:multiple="$f['multiple'] ?? false"
:data-tags="! empty($f['tags']) ? 'true' : null"
:data-placeholder="$f['placeholder'] ?? null"
x-model="formData.{{ $f['name'] }}"
/>
@elseif (($f['type'] ?? 'text') === 'color')
{{-- Warna: pemilih warna + kode heksa "#RRGGBB" (opsional) --}}
<div class="field">
<label class="field__label" for="field-form_{{ $f['name'] }}">{{ $f['label'] }} <span class="field__optional">(opsional)</span></label>
<div class="satu-inline__color">
<input type="color" class="satu-inline__picker" aria-label="Pilih warna" x-bind:value="formData.{{ $f['name'] }} || undefined" x-on:input="formData.{{ $f['name'] }} = $event.target.value.toUpperCase()">
<input id="field-form_{{ $f['name'] }}" class="field__input" maxlength="7" pattern="#[0-9A-Fa-f]{6}" x-model="formData.{{ $f['name'] }}" placeholder="#RRGGBB" autocomplete="off">
</div>
</div>
@else
<x-form.field
:name="'form_'.$f['name']"
@@ -233,6 +267,7 @@
x-model="formData.{{ $f['name'] }}"
/>
@endif
@if ($f['wide'] ?? false) </div> @endif
@endforeach
</div>