[Operator] Kelengkapan Laman Konsentrasi
This commit is contained in:
@@ -622,6 +622,32 @@ tbody > tr[hidden] { display: none; }
|
||||
.dialog--stack.dialog--tall:has(select.field__select) { overflow: auto; }
|
||||
}
|
||||
.satu-form select[multiple] { min-height: 11rem; }
|
||||
/* Isian selebar dua kolom di formulir berkolom ('span' => 2) */
|
||||
.dialog--wide .satu-form__span { grid-column: span 2; }
|
||||
|
||||
/* Daftar centang di formulir modal (mis. mata kuliah anggota grup): keterangan, kotak cari, daftar bergulir, jumlah tercentang */
|
||||
.checklist { display: grid; gap: var(--space-xs); }
|
||||
.checklist .field__label { margin: 0; }
|
||||
.checklist__hint, .checklist__empty, .checklist__count { margin: 0; font-size: var(--text-sm); line-height: 1.5; color: var(--color-muted); }
|
||||
.checklist__tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-md); }
|
||||
.checklist__tools .field__input { flex: 1 1 14rem; }
|
||||
.checklist__only { min-height: 2.25rem; font-size: var(--text-sm); }
|
||||
.checklist__list {
|
||||
/* Di layar pendek daftar memendek supaya seluruh formulir (dan tombol Simpan) tetap muat tanpa menggulir dialog */
|
||||
max-height: clamp(8rem, 100dvh - 36rem, 16rem);
|
||||
overflow-y: auto;
|
||||
padding-inline: var(--space-sm);
|
||||
border: 1px solid var(--color-edge);
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--color-surface);
|
||||
}
|
||||
.checklist__item { align-items: flex-start; min-height: 0; padding-block: var(--space-xs); font-size: var(--text-sm); line-height: 1.45; }
|
||||
.checklist__item .check__input { margin-block-start: 0.0625rem; }
|
||||
.checklist__item + .checklist__item { border-block-start: var(--rule-hair) solid var(--color-rule); }
|
||||
.checklist__note { color: var(--color-muted); }
|
||||
.checklist__list .checklist__empty { padding-block: var(--space-sm); }
|
||||
/* Formulir berdaftar centang lebih tinggi dari layar pendek: dialog digulir (mengalahkan overflow: visible untuk Select2) */
|
||||
.dialog.dialog--scroll, .dialog.dialog--scroll:has(select.field__select) { overflow: auto; }
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
Beranda operator
|
||||
@@ -694,6 +720,7 @@ button, a, summary, label, select, [role="tab"] { touch-action: manipulation; }
|
||||
.satu-pager { grid-column: 1 / -1; justify-content: center; flex-wrap: nowrap; padding-block-start: var(--space-3xs); }
|
||||
|
||||
.satu-form, .satu-form__actions .btn { grid-template-columns: minmax(0, 1fr); }
|
||||
.satu-form .satu-form__span { grid-column: auto; }
|
||||
.satu-form__actions .btn { flex: 1 1 100%; }
|
||||
|
||||
.panel-title { flex-wrap: wrap; gap: var(--space-xs); }
|
||||
|
||||
@@ -936,6 +936,27 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
select.value = next === null || next === undefined ? '' : String(next);
|
||||
window.jQuery(select).trigger('change.select2');
|
||||
});
|
||||
|
||||
// Daftar centang bertingkat: pilihan yang bukan milik induk terpilih dibuang (mis. ganti kurikulum)
|
||||
Object.entries(this.form?.checklists ?? {}).forEach(([name, list]) => {
|
||||
const allowed = new Set((list.options[this.formData[list.parent]] ?? []).map(([value]) => Number(value)));
|
||||
const current = Array.isArray(this.formData[name]) ? this.formData[name] : [];
|
||||
const kept = current.filter((value) => allowed.has(Number(value)));
|
||||
if (kept.length !== current.length) this.formData[name] = kept;
|
||||
});
|
||||
},
|
||||
|
||||
// Pilihan daftar centang {name} menurut nilai induknya: [[nilai, label, id pemilik|null, nama pemilik|null], ...]
|
||||
checklist(name) {
|
||||
const list = (this.form?.checklists ?? {})[name];
|
||||
return list ? (list.options[this.formData[list.parent]] ?? []) : [];
|
||||
},
|
||||
|
||||
// Pilihan yang tampil: cocok dengan kata cari dan, bila diminta, hanya yang sudah dicentang
|
||||
checklistShown(name, term, pickedOnly) {
|
||||
const q = String(term ?? '').trim().toLowerCase();
|
||||
const picked = new Set((Array.isArray(this.formData[name]) ? this.formData[name] : []).map(Number));
|
||||
return this.checklist(name).filter(([value, label]) => (q === '' || String(label).toLowerCase().includes(q)) && (!pickedOnly || picked.has(Number(value))));
|
||||
},
|
||||
|
||||
openForm() {
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
kolom 'swatch' => true (kotak warna + kode dari row.{key}), isian form type 'color' (pemilih warna + kode heksa), dan
|
||||
isian select bertingkat 'dependsOn' => nama isian induk + 'optionsBy' => [nilai induk => [[nilai, label], ...]] (pilihan
|
||||
dibangun ulang saat induk berubah; 'search' => true selalu menampilkan kolom cari; 'emptyHint' teks bila induk terpilih tapi tak ada pilihan), 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),
|
||||
'placeholder' (teks placeholder select), isian 'type' => 'checklist' (daftar centang banyak pilihan yang isinya mengikuti isian
|
||||
induk: 'dependsOn' + 'optionsBy' => [nilai induk => [[nilai, label, id pemilik|null, nama pemilik|null], ...]], nilai = larik id;
|
||||
'hint' selalu tampil, 'search' = placeholder kotak cari, 'item' = nama butir, 'owner' = sebutan pemilik, mis. "grup"),
|
||||
$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', 'withFilters' (opsional: nama filter yang nilainya ikut dikirim saat simpan), 'storeUrl', 'updateUrl' ("__ID__"), 'fields' => [['name', 'label', 'type' =>
|
||||
@@ -63,7 +65,7 @@
|
||||
'ownRowsOnly' => $ownRowsOnly,
|
||||
'viewUrl' => $viewUrl,
|
||||
'destroyUrl' => $destroyUrl,
|
||||
'form' => $form ? ['withFilters' => $form['withFilters'] ?? [], 'cascades' => collect($form['fields'])->filter(fn (array $f): bool => isset($f['dependsOn']))->map(fn (array $f): array => ['field' => $f['name'], 'parent' => $f['dependsOn'], 'options' => $f['optionsBy'], 'emptyHint' => $f['emptyHint'] ?? null, 'label' => mb_strtolower($f['label']), 'parentLabel' => mb_strtolower((string) collect($form['fields'])->firstWhere('name', $f['dependsOn'])['label'])])->values()->all(), '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'] ?? [], 'checklists' => collect($form['fields'])->filter(fn (array $f): bool => ($f['type'] ?? null) === 'checklist')->mapWithKeys(fn (array $f): array => [$f['name'] => ['parent' => $f['dependsOn'], 'options' => $f['optionsBy']]])->all(), 'cascades' => collect($form['fields'])->filter(fn (array $f): bool => isset($f['dependsOn']) && ($f['type'] ?? null) !== 'checklist')->map(fn (array $f): array => ['field' => $f['name'], 'parent' => $f['dependsOn'], 'options' => $f['optionsBy'], 'emptyHint' => $f['emptyHint'] ?? null, 'label' => mb_strtolower($f['label']), 'parentLabel' => mb_strtolower((string) collect($form['fields'])->firstWhere('name', $f['dependsOn'])['label'])])->values()->all(), 'storeUrl' => $form['storeUrl'], 'updateUrl' => $form['updateUrl'] ?? null, 'fields' => array_map(fn (array $f): array => ['name' => $f['name'], 'default' => $f['default'] ?? ((($f['multiple'] ?? false) || ($f['type'] ?? null) === 'checklist') ? [] : '')], $form['fields'])] : null,
|
||||
// Kolom dinamis: kolom awal dari data halaman pertama agar render awal langsung punya kepala dan sel
|
||||
'columns' => $dynamicColumns
|
||||
? collect($data['columns'] ?? [])->map(fn (array $c): array => ['key' => $c['key'], 'label' => $c['label'], 'num' => (bool) ($c['num'] ?? false), 'meter' => (bool) ($c['meter'] ?? false)])->values()->all()
|
||||
@@ -401,8 +403,13 @@
|
||||
@if ($form)
|
||||
{{-- Modal formulir tambah/ubah: kolom menurut $form['fields'], nilai di formData.
|
||||
Formulir pendek (paling banyak enam isian) satu kolom, isian berurut ke bawah; yang lebih panjang tetap berkolom. --}}
|
||||
@php $fieldCount = count($form['fields']); @endphp
|
||||
<dialog x-ref="form" @class(['dialog', 'dialog--wide' => $fieldCount > 6, 'dialog--stack' => $fieldCount <= 6, 'dialog--tall' => $fieldCount >= 5 && $fieldCount <= 6]) aria-labelledby="satu-form-judul" x-on:click="formBackdrop($event)" x-on:close="setTimeout(() => $refs.form.open || (editing = null), 300)">
|
||||
@php
|
||||
$fieldCount = count($form['fields']);
|
||||
// Formulir berdaftar centang: lebar (isian pendek sebaris, daftar selebar penuh) dan selalu bisa digulir
|
||||
$hasChecklist = collect($form['fields'])->contains(fn (array $f): bool => ($f['type'] ?? null) === 'checklist');
|
||||
$stacked = $fieldCount <= 6 && ! $hasChecklist;
|
||||
@endphp
|
||||
<dialog x-ref="form" @class(['dialog', 'dialog--wide' => ! $stacked, 'dialog--stack' => $stacked, 'dialog--tall' => $stacked && $fieldCount >= 5, 'dialog--scroll' => $hasChecklist]) 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()" x-effect="syncCascades()" novalidate>
|
||||
<div class="dialog__head">
|
||||
<span class="dialog__icon" aria-hidden="true"><x-heroicon-o-pencil-square /></span>
|
||||
@@ -413,7 +420,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
|
||||
{{-- 'span' => 2: isian selebar dua kolom (mis. nama panjang di sebelah kode pendek) --}}
|
||||
@if ($f['wide'] ?? false) <div class="col-span-full"> @elseif (($f['span'] ?? 1) === 2) <div class="satu-form__span"> @endif
|
||||
@if (($f['type'] ?? 'text') === 'select')
|
||||
<x-form.select
|
||||
:name="'form_'.$f['name']"
|
||||
@@ -429,6 +437,43 @@
|
||||
:data-placeholder="$f['placeholder'] ?? null"
|
||||
x-model="formData.{{ $f['name'] }}"
|
||||
/>
|
||||
@elseif (($f['type'] ?? 'text') === 'checklist')
|
||||
{{-- Daftar centang banyak pilihan; isinya mengikuti isian induk (checklist()), nilai = larik id di formData.
|
||||
Awalan cl: komponen ini bersarang di dalam x-data tabel, jadi nama tidak boleh menabrak. --}}
|
||||
@php
|
||||
$cid = 'field-form_'.$f['name'];
|
||||
$cname = $f['name'];
|
||||
$cparent = mb_strtolower((string) collect($form['fields'])->firstWhere('name', $f['dependsOn'])['label']);
|
||||
$citem = $f['item'] ?? 'pilihan';
|
||||
@endphp
|
||||
<div class="field checklist" x-data="{ clCari: '', clDipilih: false }" x-effect="(editing, clCari = '', clDipilih = false)">
|
||||
<p class="field__label" id="{{ $cid }}-label">{{ $f['label'] }} @unless ($f['required'] ?? false) <span class="field__optional">(opsional)</span> @endunless</p>
|
||||
@if ($f['hint'] ?? null)
|
||||
<p class="checklist__hint" id="{{ $cid }}-hint">{{ $f['hint'] }}</p>
|
||||
@endif
|
||||
<div class="checklist__tools" x-show="checklist('{{ $cname }}').length > 0">
|
||||
<input type="search" class="field__input" placeholder="{{ $f['search'] ?? 'Cari' }}" aria-label="{{ $f['search'] ?? 'Cari '.$citem }}" autocomplete="off" x-model="clCari" x-on:keydown.enter.prevent>
|
||||
<label class="check checklist__only">
|
||||
<input type="checkbox" class="check__input" x-model="clDipilih">
|
||||
<span>Hanya yang dicentang</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="checklist__list" role="group" aria-labelledby="{{ $cid }}-label" @if ($f['hint'] ?? null) aria-describedby="{{ $cid }}-hint" @endif x-show="checklist('{{ $cname }}').length > 0">
|
||||
<template x-for="option in checklistShown('{{ $cname }}', clCari, clDipilih)" x-bind:key="option[0]">
|
||||
<label class="check checklist__item">
|
||||
<input type="checkbox" class="check__input" x-bind:value="option[0]" x-model.number="formData.{{ $cname }}">
|
||||
<span>
|
||||
<span x-text="option[1]"></span>
|
||||
{{-- Sudah dipegang pemilik lain (mis. grup lain): mencentangnya memindahkan --}}
|
||||
<span class="checklist__note" x-show="option[2] && option[2] !== editing" x-text="'(sekarang di {{ $f['owner'] ?? 'kelompok' }} ' + option[3] + ')'"></span>
|
||||
</span>
|
||||
</label>
|
||||
</template>
|
||||
<p class="checklist__empty" x-show="checklistShown('{{ $cname }}', clCari, clDipilih).length === 0">Tidak ada {{ $citem }} yang cocok.</p>
|
||||
</div>
|
||||
<p class="checklist__empty" x-show="checklist('{{ $cname }}').length === 0" x-text="formData.{{ $f['dependsOn'] }} ? 'Belum ada {{ $citem }} di {{ $cparent }} ini.' : 'Pilih {{ $cparent }} terlebih dahulu untuk menampilkan daftar {{ $citem }}.'"></p>
|
||||
<p class="checklist__count" aria-live="polite" x-show="checklist('{{ $cname }}').length > 0" x-text="(formData.{{ $cname }} ?? []).length + ' dari ' + checklist('{{ $cname }}').length + ' {{ $citem }} dicentang'"></p>
|
||||
</div>
|
||||
@elseif (($f['type'] ?? 'text') === 'color')
|
||||
{{-- Warna: pemilih warna + kode heksa "#RRGGBB" (opsional) --}}
|
||||
<div class="field">
|
||||
@@ -453,7 +498,7 @@
|
||||
x-model="formData.{{ $f['name'] }}"
|
||||
/>
|
||||
@endif
|
||||
@if ($f['wide'] ?? false) </div> @endif
|
||||
@if (($f['wide'] ?? false) || ($f['span'] ?? 1) === 2) </div> @endif
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user