[Operator] Perbaikan Laman Kegiatan
This commit is contained in:
+22
-21
@@ -713,33 +713,34 @@ button, a, summary, label, select, [role="tab"] { touch-action: manipulation; }
|
||||
.cal__count { margin: 0; color: var(--color-muted); font-size: var(--text-sm); }
|
||||
.cal { width: 100%; min-width: 42rem; table-layout: fixed; border-collapse: collapse; }
|
||||
.cal th { padding: var(--space-2xs); border-block-end: var(--rule-hair) solid var(--color-rule); color: var(--color-muted); font-size: var(--text-sm); font-weight: 600; text-align: start; }
|
||||
.cal__day { height: 6rem; padding: var(--space-2xs); border: var(--rule-hair) solid var(--color-rule); vertical-align: top; }
|
||||
.cal__day { padding: var(--space-3xs) var(--space-2xs); border: var(--rule-hair) solid var(--color-rule); border-block-end: 0; vertical-align: top; }
|
||||
.cal__num { font-weight: 600; font-variant-numeric: tabular-nums; }
|
||||
.cal__day--out .cal__num { color: var(--color-muted); }
|
||||
.cal__events { display: grid; gap: var(--space-3xs); margin: var(--space-3xs) 0 0; padding: 0; list-style: none; }
|
||||
.cal__event {
|
||||
position: relative;
|
||||
padding: var(--space-3xs) var(--space-2xs) var(--space-3xs) calc(var(--space-2xs) + 0.875rem);
|
||||
/* Jalur kegiatan: sel kosong menjaga garis tegak kalender; sel berisi (colspan) menjangkau beberapa hari tanpa garis di tengah */
|
||||
.cal__slot { height: 1.75rem; padding: 0.125rem 0; border-inline: var(--rule-hair) solid var(--color-rule); }
|
||||
.cal__week > tr:last-child > .cal__slot { border-block-end: var(--rule-hair) solid var(--color-rule); }
|
||||
.cal__bar {
|
||||
display: block;
|
||||
height: 1.5rem;
|
||||
margin-inline: 0.125rem;
|
||||
padding-inline: var(--space-2xs);
|
||||
/* Warna penuh jenis kegiatan, sama dengan kotak warna pada legenda (.swatch__chip): tanpa warna = kotak kosong bertepi */
|
||||
border: var(--rule-hair) solid var(--color-rule);
|
||||
border-radius: var(--radius-inner);
|
||||
background: var(--color-surface);
|
||||
background: var(--swatch, transparent);
|
||||
color: var(--color-ink);
|
||||
font-size: var(--text-xs);
|
||||
line-height: var(--text-xs--line-height);
|
||||
overflow-wrap: anywhere;
|
||||
white-space: normal;
|
||||
line-height: calc(1.5rem - 2 * var(--rule-hair));
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* Kotak warna jenis kegiatan (kunci ke legenda), bukan hiasan */
|
||||
.cal__event::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset-inline-start: var(--space-2xs);
|
||||
top: calc(var(--space-3xs) + 0.25em);
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
border-radius: 2px;
|
||||
background: var(--swatch, var(--color-rule));
|
||||
}
|
||||
|
||||
/* Teks di atas warna penuh: hitam bila warnanya terang, putih bila gelap (dipilih server dari luminansi) */
|
||||
.cal__bar--on-light { color: var(--color-on-swatch-dark); }
|
||||
.cal__bar--on-dark { color: var(--color-on-swatch-light); }
|
||||
/* Kegiatan berlanjut dari/ke minggu lain: ujung rata menyentuh tepi minggu supaya bar terbaca tersambung */
|
||||
.cal__bar--before { margin-inline-start: 0; border-inline-start-width: 0; border-start-start-radius: 0; border-end-start-radius: 0; }
|
||||
.cal__bar--after { margin-inline-end: 0; border-inline-end-width: 0; border-start-end-radius: 0; border-end-end-radius: 0; }
|
||||
.cal-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--space-2xs) var(--space-md); margin: 0; padding: 0; list-style: none; }
|
||||
.cal-legend__item { display: flex; align-items: center; gap: var(--space-2xs); font-size: var(--text-sm); }
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
--color-accent-text: oklch(41% 0.17 27);
|
||||
--color-focus: oklch(50% 0.2 27);
|
||||
|
||||
/* Teks di atas warna data pengguna (warna jenis kegiatan): hitam atau putih murni, sama di tema terang dan gelap.
|
||||
Dipilih per warna lewat luminansi (AcademicCalendar) sehingga kontrasnya minimal sekitar 4,6:1. */
|
||||
--color-on-swatch-dark: oklch(0% 0 0);
|
||||
--color-on-swatch-light: oklch(100% 0 0);
|
||||
|
||||
/* Aurora: warna lapisan latar agar kaca punya sesuatu untuk dikaburkan */
|
||||
--color-aurora-rose: oklch(87% 0.09 18);
|
||||
--color-aurora-amber: oklch(92% 0.1 88);
|
||||
|
||||
+51
-13
@@ -625,8 +625,13 @@ Alpine.data('satuTable', (config) => ({
|
||||
return Array.from({ length: Math.min(5, this.pages) }, (_, i) => start + i);
|
||||
},
|
||||
|
||||
// Baris yang boleh dicentang
|
||||
get pickable() {
|
||||
return this.ownRowsOnly ? this.view.filter((row) => row.form) : this.view;
|
||||
},
|
||||
|
||||
get allPicked() {
|
||||
return this.view.length > 0 && this.view.every((row) => this.picked.includes(row.id));
|
||||
return this.pickable.length > 0 && this.pickable.every((row) => this.picked.includes(row.id));
|
||||
},
|
||||
|
||||
reset() {
|
||||
@@ -645,7 +650,7 @@ Alpine.data('satuTable', (config) => ({
|
||||
},
|
||||
|
||||
toggleAll() {
|
||||
const ids = this.view.map((row) => row.id);
|
||||
const ids = this.pickable.map((row) => row.id);
|
||||
this.picked = this.allPicked ? this.picked.filter((id) => !ids.includes(id)) : [...new Set([...this.picked, ...ids])];
|
||||
},
|
||||
|
||||
@@ -851,6 +856,8 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
// Opsional: tautan Lihat per baris ("__ID__" diganti id) dan penghapusan sungguhan (POST {ids})
|
||||
viewUrl: config.viewUrl ?? null,
|
||||
destroyUrl: config.destroyUrl ?? null,
|
||||
// true: hanya baris yang membawa row.form yang bisa dicentang/dihapus (mis. kegiatan milik unit sendiri)
|
||||
ownRowsOnly: config.ownRowsOnly ?? false,
|
||||
token: config.token ?? '',
|
||||
pending: [],
|
||||
// Opsional: formulir tambah/ubah lewat modal ({storeUrl, updateUrl, fields:[{name, default}]}); baris memberi row.form
|
||||
@@ -871,8 +878,13 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
return Array.from({ length: Math.min(5, this.pages) }, (_, i) => start + i);
|
||||
},
|
||||
|
||||
// Baris yang boleh dicentang
|
||||
get pickable() {
|
||||
return this.ownRowsOnly ? this.view.filter((row) => row.form) : this.view;
|
||||
},
|
||||
|
||||
get allPicked() {
|
||||
return this.view.length > 0 && this.view.every((row) => this.picked.includes(row.id));
|
||||
return this.pickable.length > 0 && this.pickable.every((row) => this.picked.includes(row.id));
|
||||
},
|
||||
|
||||
// Filter, kata cari, atau jumlah per halaman berubah: kembali ke halaman 1
|
||||
@@ -913,6 +925,10 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
const isNew = this.editing === 'new';
|
||||
const url = isNew ? this.form.storeUrl : this.form.updateUrl.replace('__ID__', encodeURIComponent(this.editing));
|
||||
const body = Object.fromEntries(Object.entries(this.formData).map(([k, v]) => [k, v === '' ? null : v]));
|
||||
// Filter yang ikut dikirim (mis. periode akademik yang sedang dipilih); filter kosong tidak dikirim
|
||||
(this.form.withFilters ?? []).forEach((name) => {
|
||||
if (this.values[name] !== '' && this.values[name] !== null && this.values[name] !== false) body[name] = this.values[name];
|
||||
});
|
||||
this.loading = true;
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
@@ -984,7 +1000,7 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
},
|
||||
|
||||
toggleAll() {
|
||||
const ids = this.view.map((row) => row.id);
|
||||
const ids = this.pickable.map((row) => row.id);
|
||||
this.picked = this.allPicked ? this.picked.filter((id) => !ids.includes(id)) : [...new Set([...this.picked, ...ids])];
|
||||
},
|
||||
|
||||
@@ -1129,7 +1145,7 @@ Alpine.data('bioDetail', (config) => ({
|
||||
}));
|
||||
|
||||
/*
|
||||
* Kegiatan Akademik (Portal operator, akun DB lama): tabel jenis kegiatan dengan tambah/ubah sebaris dan hapus
|
||||
* Kegiatan Akademik (Portal operator, akun DB lama): tabel jenis kegiatan dengan tambah/ubah lewat modal dan hapus
|
||||
* berdialog. Baris disaring dan dihalamankan di sisi klien (jumlahnya puluhan); setiap simpan mengirim JSON dan
|
||||
* memakai daftar segar dari server.
|
||||
*/
|
||||
@@ -1177,17 +1193,27 @@ Alpine.data('satuKegiatan', (config) => ({
|
||||
startInsert() {
|
||||
this.editing = 'new';
|
||||
this.form = { kode: '', nama: '', warna: '' };
|
||||
this.$nextTick(() => this.$refs.nama?.focus());
|
||||
this.openForm();
|
||||
},
|
||||
|
||||
startEdit(row) {
|
||||
this.editing = row.id;
|
||||
this.form = { kode: row.kode, nama: row.nama, warna: row.warna ?? '' };
|
||||
this.openForm();
|
||||
},
|
||||
|
||||
openForm() {
|
||||
const dialog = this.$refs.form;
|
||||
if (dialog && !dialog.open) dialog.showModal();
|
||||
this.$nextTick(() => this.$refs.nama?.focus());
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.editing = null;
|
||||
closeForm() {
|
||||
this.$refs.form?.close();
|
||||
},
|
||||
|
||||
formBackdrop(event) {
|
||||
if (event.target === this.$refs.form) this.closeForm();
|
||||
},
|
||||
|
||||
async request(url, method, body) {
|
||||
@@ -1219,7 +1245,7 @@ Alpine.data('satuKegiatan', (config) => ({
|
||||
try {
|
||||
const data = await this.request(url, isNew ? 'POST' : 'PUT', body);
|
||||
this.rows = data.rows;
|
||||
this.editing = null;
|
||||
this.closeForm();
|
||||
window.toast('success', data.message);
|
||||
} catch (error) {
|
||||
window.toast('danger', error.message);
|
||||
@@ -1470,7 +1496,8 @@ document.addEventListener('click', (event) => {
|
||||
* Select2 untuk semua <select> formulir (form.select dan <select class="field__select">): pencarian pada
|
||||
* daftar panjang, tombol hapus (allowClear) dan placeholder "Pilih {nama kolom}". Pemilihan diteruskan ke
|
||||
* x-model/x-on:change Alpine lewat event bawaan; perubahan dari Alpine disinkronkan balik ke tampilan.
|
||||
* Atribut: data-no-clear (tanpa tombol hapus), data-no-select2 (biarkan <select> bawaan).
|
||||
* Atribut: data-no-clear (tanpa tombol hapus), data-no-select2 (biarkan <select> bawaan), data-placeholder (teks
|
||||
* placeholder sendiri), data-tags (daftar yang bisa dicari sekaligus boleh membuat nilai baru dengan mengetik).
|
||||
*/
|
||||
const SELECT2_ID = {
|
||||
noResults: () => 'Data tidak ditemukan',
|
||||
@@ -1501,7 +1528,8 @@ const enhanceSelect = (el) => {
|
||||
|
||||
const hasEmpty = [...el.options].some((option) => option.value === '');
|
||||
const name = labelOf(el);
|
||||
const placeholder = name ? `Pilih ${name}` : 'Pilih...';
|
||||
const placeholder = el.dataset.placeholder || (name ? `Pilih ${name}` : 'Pilih...');
|
||||
const tags = el.hasAttribute('data-tags');
|
||||
const $el = $(el);
|
||||
|
||||
// Di dalam <dialog> (lapisan atas) dropdown harus ikut di dalam dialog; di body ia tertutup modal
|
||||
@@ -1511,8 +1539,16 @@ const enhanceSelect = (el) => {
|
||||
width: '100%',
|
||||
placeholder: hasEmpty ? placeholder : undefined,
|
||||
allowClear: !noClear && hasEmpty,
|
||||
language: SELECT2_ID,
|
||||
minimumResultsForSearch: el.options.length > 8 ? 0 : Infinity,
|
||||
language: tags ? { ...SELECT2_ID, noResults: () => 'Ketik untuk membuat nama baru' } : SELECT2_ID,
|
||||
tags,
|
||||
// Nama yang sudah ada (tanpa memandang huruf) dipilih dari daftar, bukan dibuat ulang
|
||||
createTag: tags ? (params) => {
|
||||
const term = params.term.trim();
|
||||
if (term === '' || [...el.options].some((option) => option.text.trim().toLowerCase() === term.toLowerCase())) return null;
|
||||
return { id: term, text: term, isNew: true };
|
||||
} : undefined,
|
||||
templateResult: tags ? (item) => (item.isNew ? $('<span>').text(`Buat baru: ${item.text}`) : item.text) : undefined,
|
||||
minimumResultsForSearch: tags || el.options.length > 8 ? 0 : Infinity,
|
||||
dropdownCssClass: 'select2-glass',
|
||||
selectionCssClass: 'select2-glass',
|
||||
dropdownParent: dialog ? $(dialog) : $(document.body),
|
||||
@@ -1534,6 +1570,8 @@ const enhanceSelect = (el) => {
|
||||
Alpine.effect(() => {
|
||||
const value = Alpine.evaluate(el, model.value);
|
||||
const next = value === null || value === undefined ? '' : String(value);
|
||||
// Nilai baru buatan pengguna belum ada sebagai <option> (mis. saat mengubah baris yang namanya baru dibuat)
|
||||
if (tags && next !== '' && ![...el.options].some((option) => option.value === next)) el.appendChild(new Option(next, next));
|
||||
// x-model sudah mengubah nilai <select> asli; Select2 tetap perlu menyegarkan tampilannya
|
||||
Alpine.nextTick(() => {
|
||||
if (String($el.val() ?? '') !== next) $el.val(next);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{{--
|
||||
Monitoring Kalender Akademik (akun DB lama): filter periode/bulan (formulir GET, dimuat di tempat), grid bulanan
|
||||
minggu mulai Minggu seperti SATU, dan legenda warna jenis kegiatan. Tiga panel bersaudara.
|
||||
minggu mulai Minggu seperti SATU (kegiatan berupa bar yang tersambung dari TMT sampai TST), dan legenda warna jenis kegiatan.
|
||||
Tiga panel bersaudara.
|
||||
--}}
|
||||
<x-satu.frame :page="$page" :crumbs="$crumbs" :note="$note">
|
||||
<x-glass.panel padding="sm" as="section" aria-label="Filter data">
|
||||
@@ -30,27 +31,38 @@
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($grid['weeks'] as $week)
|
||||
@foreach ($grid['weeks'] as $week)
|
||||
{{-- Satu <tbody> per minggu: baris angka hari, lalu jalur bar kegiatan yang tersambung dari TMT sampai TST --}}
|
||||
<tbody class="cal__week">
|
||||
<tr>
|
||||
@foreach ($week as $day)
|
||||
@foreach ($week['days'] as $day)
|
||||
<td @class(['cal__day', 'cal__day--out' => ! $day['inMonth']])>
|
||||
<span class="cal__num">{{ $day['date']->day }}</span>
|
||||
@if ($day['events'])
|
||||
<ul class="cal__events">
|
||||
@foreach ($day['events'] as $event)
|
||||
<li class="cal__event" @if ($event['warna']) style="--swatch: {{ $event['warna'] }}" @endif>
|
||||
{{ $event['jenis'] }}@if ($event['keterangan'] !== '–'): {{ $event['keterangan'] }}@endif
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@foreach ($week['lanes'] as $lane)
|
||||
<tr class="cal__lane">
|
||||
@foreach ($lane as $cell)
|
||||
@if ($cell['event'])
|
||||
@php
|
||||
$event = $cell['event'];
|
||||
$label = $event['jenis'].($event['keterangan'] !== '–' ? ': '.$event['keterangan'] : '');
|
||||
$range = $event['mulai'] === $event['selesai'] ? $event['mulai'] : $event['mulai'].' sampai '.$event['selesai'];
|
||||
@endphp
|
||||
<td colspan="{{ $cell['span'] }}" class="cal__slot" title="{{ $label }} ({{ $range }})">
|
||||
<span @class(['cal__bar', 'cal__bar--before' => $cell['before'], 'cal__bar--after' => $cell['after'], 'cal__bar--on-light' => $event['teksGelap'] === true, 'cal__bar--on-dark' => $event['teksGelap'] === false]) @if ($event['warna']) style="--swatch: {{ $event['warna'] }}" @endif>
|
||||
{{ $label }}<span class="visually-hidden"> ({{ $range }})</span>
|
||||
</span>
|
||||
</td>
|
||||
@else
|
||||
<td class="cal__slot cal__slot--blank"></td>
|
||||
@endif
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@endforeach </table>
|
||||
</x-ui.table>
|
||||
</x-glass.panel>
|
||||
@endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{{--
|
||||
Kegiatan Akademik (akun DB lama): markup daftar SATU yang sama (bilah cari + Tambah, kolom Kode, Nama, Background,
|
||||
Aksi, satu-foot), dengan tambah/ubah sebaris dan hapus berdialog seperti SATU. Data dan simpan lewat JSON
|
||||
Aksi, satu-foot), dengan tambah/ubah lewat modal dan hapus berdialog. Data dan simpan lewat JSON
|
||||
(satuKegiatan di app.js); alamat halaman tidak berubah.
|
||||
--}}
|
||||
@php
|
||||
@@ -20,7 +20,7 @@
|
||||
</div>
|
||||
|
||||
<div class="satu-bar__tools">
|
||||
<x-ui.button variant="primary" icon="plus" size="sm" x-on:click="startInsert()" x-bind:disabled="editing === 'new'">Tambah</x-ui.button>
|
||||
<x-ui.button variant="primary" icon="plus" size="sm" x-on:click="startInsert()">Tambah</x-ui.button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -35,92 +35,24 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{-- Baris isian baru (seperti insert-row SATU) --}}
|
||||
<template x-if="editing === 'new'">
|
||||
<tr class="satu-inline">
|
||||
<td>
|
||||
<label class="visually-hidden" for="kegiatan-kode-baru">Kode</label>
|
||||
<input id="kegiatan-kode-baru" class="field__input" maxlength="5" x-model="form.kode" x-bind:disabled="!ready" placeholder="Kode" x-on:keydown.enter.prevent="save()" x-on:keydown.escape.prevent="cancel()">
|
||||
</td>
|
||||
<td>
|
||||
<label class="visually-hidden" for="kegiatan-nama-baru">Nama kegiatan akademik</label>
|
||||
<input id="kegiatan-nama-baru" class="field__input" maxlength="100" x-model="form.nama" x-ref="nama" placeholder="Contoh: Perkuliahan Tahap I" required placeholder="Nama kegiatan akademik" x-on:keydown.enter.prevent="save()" x-on:keydown.escape.prevent="cancel()">
|
||||
</td>
|
||||
<td>
|
||||
<div class="satu-inline__color">
|
||||
<label class="visually-hidden" for="kegiatan-pilih-warna-baru">Pilih warna</label>
|
||||
<input id="kegiatan-pilih-warna-baru" type="color" class="satu-inline__picker" x-bind:value="form.warna || undefined" x-on:input="form.warna = $event.target.value.toUpperCase()" x-bind:disabled="!ready">
|
||||
<label class="visually-hidden" for="kegiatan-warna-baru">Kode warna</label>
|
||||
<input id="kegiatan-warna-baru" class="field__input" maxlength="7" pattern="#[0-9A-Fa-f]{6}" x-model="form.warna" x-bind:disabled="!ready" placeholder="#RRGGBB" x-on:keydown.enter.prevent="save()" x-on:keydown.escape.prevent="cancel()">
|
||||
</div>
|
||||
</td>
|
||||
<td class="table__actions">
|
||||
<x-ui.button variant="ghost" size="sm" icon="check" :icon-only="true" aria-label="Simpan" x-on:click="save()" x-bind:disabled="saving" />
|
||||
<x-ui.button variant="ghost" size="sm" icon="x-mark" :icon-only="true" aria-label="Batal" x-on:click="cancel()" />
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
<template x-for="row in view" x-bind:key="row.id">
|
||||
<tr x-bind:class="editing === row.id ? 'satu-inline' : ''">
|
||||
<template x-if="editing !== row.id">
|
||||
<td class="table__title" x-text="row.kode"></td>
|
||||
</template>
|
||||
<template x-if="editing === row.id">
|
||||
<td>
|
||||
<label class="visually-hidden" x-bind:for="'kegiatan-kode-' + row.id">Kode</label>
|
||||
<input class="field__input" maxlength="5" placeholder="Contoh: UTS" x-bind:id="'kegiatan-kode-' + row.id" x-model="form.kode" x-bind:disabled="!ready" x-on:keydown.enter.prevent="save()" x-on:keydown.escape.prevent="cancel()">
|
||||
</td>
|
||||
</template>
|
||||
|
||||
<template x-if="editing !== row.id">
|
||||
<td x-text="row.nama"></td>
|
||||
</template>
|
||||
<template x-if="editing === row.id">
|
||||
<td>
|
||||
<label class="visually-hidden" x-bind:for="'kegiatan-nama-' + row.id">Nama kegiatan akademik</label>
|
||||
<input class="field__input" maxlength="100" x-bind:id="'kegiatan-nama-' + row.id" x-model="form.nama" x-ref="nama" placeholder="Contoh: Perkuliahan Tahap I" required x-on:keydown.enter.prevent="save()" x-on:keydown.escape.prevent="cancel()">
|
||||
</td>
|
||||
</template>
|
||||
|
||||
<template x-if="editing !== row.id">
|
||||
<td>
|
||||
<span class="swatch">
|
||||
<i class="swatch__chip" aria-hidden="true" x-bind:style="row.warna ? '--swatch: ' + row.warna : ''"></i>
|
||||
<span x-text="row.warna ?? '–'"></span>
|
||||
</span>
|
||||
</td>
|
||||
</template>
|
||||
<template x-if="editing === row.id">
|
||||
<td>
|
||||
<div class="satu-inline__color">
|
||||
<label class="visually-hidden" x-bind:for="'kegiatan-pilih-warna-' + row.id">Pilih warna</label>
|
||||
<input type="color" class="satu-inline__picker" x-bind:id="'kegiatan-pilih-warna-' + row.id" x-bind:value="form.warna || undefined" x-on:input="form.warna = $event.target.value.toUpperCase()" x-bind:disabled="!ready">
|
||||
<label class="visually-hidden" x-bind:for="'kegiatan-warna-' + row.id">Kode warna</label>
|
||||
<input class="field__input" maxlength="7" pattern="#[0-9A-Fa-f]{6}" x-bind:id="'kegiatan-warna-' + row.id" x-model="form.warna" x-bind:disabled="!ready" placeholder="#RRGGBB" x-on:keydown.enter.prevent="save()" x-on:keydown.escape.prevent="cancel()">
|
||||
</div>
|
||||
</td>
|
||||
</template>
|
||||
|
||||
<tr>
|
||||
<td class="table__title" x-text="row.kode"></td>
|
||||
<td x-text="row.nama"></td>
|
||||
<td>
|
||||
<span class="swatch">
|
||||
<i class="swatch__chip" aria-hidden="true" x-bind:style="row.warna ? '--swatch: ' + row.warna : ''"></i>
|
||||
<span x-text="row.warna ?? '–'"></span>
|
||||
</span>
|
||||
</td>
|
||||
<td class="table__actions">
|
||||
<template x-if="editing !== row.id">
|
||||
<span>
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="startEdit(row)" />
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="askRemove(row)" />
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="editing === row.id">
|
||||
<span>
|
||||
<x-ui.button variant="ghost" size="sm" icon="check" :icon-only="true" aria-label="Simpan" x-on:click="save()" x-bind:disabled="saving" />
|
||||
<x-ui.button variant="ghost" size="sm" icon="x-mark" :icon-only="true" aria-label="Batal" x-on:click="cancel()" />
|
||||
</span>
|
||||
</template>
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="startEdit(row)" />
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="askRemove(row)" />
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</template> </tbody>
|
||||
</table>
|
||||
<p class="satu-empty" x-show="filtered.length === 0 && editing !== 'new'" x-cloak>Tidak ada data yang cocok dengan pencarian.</p>
|
||||
<p class="satu-empty" x-show="filtered.length === 0" x-cloak>Tidak ada data yang cocok dengan pencarian.</p>
|
||||
</x-ui.table>
|
||||
|
||||
<div class="satu-foot">
|
||||
@@ -145,6 +77,34 @@
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
{{-- Modal tambah/ubah: kode (opsional), nama, dan warna latar kegiatan --}}
|
||||
<dialog x-ref="form" class="dialog dialog--wide" aria-labelledby="kegiatan-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()" novalidate>
|
||||
<div class="dialog__head">
|
||||
<span class="dialog__icon" aria-hidden="true"><x-heroicon-o-pencil-square /></span>
|
||||
<p id="kegiatan-form-judul" class="dialog__title" x-text="editing === 'new' ? 'Tambah kegiatan akademik' : 'Ubah kegiatan akademik'"></p>
|
||||
<x-ui.dialog-close />
|
||||
</div>
|
||||
|
||||
<div class="satu-form">
|
||||
<x-form.field name="kegiatan_kode" label="Kode" :optional="true" maxlength="5" placeholder="Contoh: UTS" x-model="form.kode" x-bind:disabled="!ready" />
|
||||
<x-form.field name="kegiatan_nama" label="Nama kegiatan akademik" maxlength="100" placeholder="Contoh: Perkuliahan Tahap I" :required="true" x-ref="nama" x-model="form.nama" />
|
||||
|
||||
<div class="field">
|
||||
<label class="field__label" for="kegiatan-warna">Background <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="form.warna || undefined" x-on:input="form.warna = $event.target.value.toUpperCase()" x-bind:disabled="!ready">
|
||||
<input id="kegiatan-warna" class="field__input" maxlength="7" pattern="#[0-9A-Fa-f]{6}" x-model="form.warna" x-bind:disabled="!ready" placeholder="#RRGGBB" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog__actions">
|
||||
<x-ui.button type="submit" variant="primary" icon="check" x-bind:disabled="saving">Simpan</x-ui.button>
|
||||
<x-ui.button variant="secondary" x-on:click="closeForm()">Batal</x-ui.button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
<dialog x-ref="dialog" class="dialog dialog--danger" aria-labelledby="kegiatan-hapus-judul" aria-describedby="kegiatan-hapus-pesan" x-on:click="backdrop($event)" x-on:close="setTimeout(() => $refs.dialog.open || (pending = null), 300)">
|
||||
<div class="dialog__body">
|
||||
<div class="dialog__head">
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user