Files
siakad/resources/views/operator/satu/kegiatan.blade.php
T
2026-11-06 14:51:38 +07:00

164 lines
12 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{--
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
(satuKegiatan di app.js); alamat halaman tidak berubah.
--}}
@php
$config = ['rows' => $rows, 'urls' => $urls, 'token' => csrf_token(), 'ready' => $ready, 'per' => $perPage[0]];
@endphp
<x-satu.frame :page="$page" :crumbs="$crumbs" :note="$note">
<div class="stack" x-data="satuKegiatan(@js($config))">
<x-glass.panel padding="none" as="section" :aria-label="'Daftar '.$page['title']">
<div class="satu-bar">
<div class="satu-bar__search field">
<label class="visually-hidden" for="satu-q">Cari data</label>
<div class="field__control">
<span class="field__icon" aria-hidden="true"><x-heroicon-o-magnifying-glass /></span>
<input id="satu-q" type="search" class="field__input" style="--pad-start: 2.5rem" placeholder="Cari {{ Str::lower($page['title']) }}" autocomplete="off" x-model.debounce.200ms="q" x-on:input="reset()">
</div>
</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>
</div>
</div>
<x-ui.table :label="'Tabel '.Str::lower($page['title'])">
<table class="table satu-table" x-bind:aria-busy="saving">
<thead>
<tr>
<th scope="col">Kode</th>
<th scope="col">Nama Kegiatan Akademik</th>
<th scope="col">Background</th>
<th scope="col" class="table__actions"><span class="visually-hidden">Aksi</span></th>
</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>
<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>
</td>
</tr>
</template>
</tbody>
</table>
<p class="satu-empty" x-show="filtered.length === 0 && editing !== 'new'" x-cloak>Tidak ada data yang cocok dengan pencarian.</p>
</x-ui.table>
<div class="satu-foot">
<p class="satu-foot__info" aria-live="polite">Halaman <span x-text="page"></span> dari <span x-text="pages"></span> (<span x-text="filtered.length"></span> data)</p>
<label class="satu-foot__per">
<span class="visually-hidden">Jumlah data per halaman</span>
<select class="field__input field__select" data-no-clear x-model.number="per" x-on:change="reset()">
@foreach ($perPage as $n)
<option value="{{ $n }}">{{ $n }} data</option>
@endforeach
</select>
</label>
<nav class="satu-pager" aria-label="Halaman data">
<button type="button" class="satu-pager__btn" aria-label="Halaman sebelumnya" x-bind:disabled="page === 1" x-on:click="go(page - 1)"><x-heroicon-m-chevron-left /></button>
<template x-for="n in window" x-bind:key="n">
<button type="button" class="satu-pager__btn" x-text="n" x-bind:aria-current="n === page ? 'page' : false" x-on:click="go(n)"></button>
</template>
<button type="button" class="satu-pager__btn" aria-label="Halaman berikutnya" x-bind:disabled="page === pages" x-on:click="go(page + 1)"><x-heroicon-m-chevron-right /></button>
</nav>
</div>
</x-glass.panel>
<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">
<span class="dialog__icon" aria-hidden="true"><x-heroicon-o-exclamation-triangle /></span>
<p id="kegiatan-hapus-judul" class="dialog__title">Hapus kegiatan akademik?</p>
<x-ui.dialog-close />
</div>
<p id="kegiatan-hapus-pesan" class="dialog__message"><span x-text="pending ? pending.kode + ' – ' + pending.nama : ''"></span> akan dihapus dari basis data. Jenis yang sudah dipakai kalender tidak bisa dihapus.</p>
<div class="dialog__actions">
<x-ui.button variant="danger" x-on:click="confirmRemove()" x-bind:disabled="saving">Ya, hapus</x-ui.button>
<x-ui.button variant="secondary" x-on:click="closeDialog()">Batal</x-ui.button>
</div>
</div>
</dialog>
</div>
</x-satu.frame>