[Operator] Perbaikan Laman Kegiatan
This commit is contained in:
@@ -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