[Operator] Integrasi view laman Dashboard, Mahasiswa, dan Pegawai
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
{{-- Bingkai halaman SIM Akademik (peran Operator): kepala halaman, jejak, dan catatan prototipe. Slot = isi. --}}
|
||||
@props(['page', 'crumbs'])
|
||||
{{-- Bingkai halaman SIM Akademik (peran Operator): kepala halaman, jejak, dan catatan (default: catatan prototipe). Slot = isi. --}}
|
||||
@props(['page', 'crumbs', 'note' => 'Tampilan prototipe untuk peran Operator. Isi tabel adalah data contoh dan tombol simpan, ubah, atau hapus tidak mengubah data.'])
|
||||
|
||||
<x-layouts.app :title="$page['title']">
|
||||
<x-ui.page-header :title="$page['title']" :description="$page['subtitle'] ?: null" :breadcrumbs="$crumbs" />
|
||||
|
||||
<div class="stack">
|
||||
<x-ui.alert tone="info">Tampilan prototipe untuk peran Operator. Isi tabel adalah data contoh dan tombol simpan, ubah, atau hapus tidak mengubah data.</x-ui.alert>
|
||||
<x-ui.alert tone="info">{{ $note }}</x-ui.alert>
|
||||
|
||||
{{ $slot }}
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
@if (count($labels) === 0)
|
||||
<x-ui.empty icon="chart-bar" title="Belum ada data" description="Grafik tampil setelah data tersedia." />
|
||||
@else
|
||||
<div class="chart__canvas" style="height: {{ $height }}" x-data="chartCanvas(@js(['type' => $type, 'labels' => $labels, 'datasets' => $datasets]))">
|
||||
{{-- Data di data-chart (bukan x-data) agar muat di tempat memperbarui grafik, bukan membuatnya ulang. --}}
|
||||
<div class="chart__canvas" style="height: {{ $height }}" x-data="chartCanvas" data-chart="{{ json_encode(['type' => $type, 'labels' => array_values($labels), 'datasets' => $datasets], JSON_THROW_ON_ERROR) }}">
|
||||
<canvas x-ref="canvas" id="{{ $id }}" role="img" aria-label="{{ $title }}"></canvas>
|
||||
</div>
|
||||
{{-- Tabel tidak mematuhi width/overflow: sembunyikan lewat pembungkus agar tidak melebar. --}}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div {{ $attributes->class(['meter', "meter--{$tone}" => $tone !== 'neutral']) }}>
|
||||
<div class="meter__head">
|
||||
<span class="meter__label" id="{{ $id }}-label">{{ $label }}</span>
|
||||
<span class="meter__text">{{ $valueText }}</span>
|
||||
<span class="meter__text" data-count>{{ $valueText }}</span>
|
||||
</div>
|
||||
<div
|
||||
class="meter__track"
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
<x-glass.panel :as="$tag" :href="$href" {{ $attributes->class('stat') }}>
|
||||
<span class="stat__icon" aria-hidden="true"><x-dynamic-component :component="'heroicon-o-'.$icon" /></span>
|
||||
<span class="stat__label">{{ $label }}</span>
|
||||
<span class="stat__value">{{ $shown }}</span>
|
||||
<span class="stat__value" data-count>{{ $shown }}</span>
|
||||
@if ($hint) <span class="stat__hint">{{ $hint }}</span> @endif
|
||||
</x-glass.panel>
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
{{--
|
||||
Halaman daftar SATU dengan data asli DB lama: markup sama dengan operator/satu/list (filter, bilah cari + tombol
|
||||
menurut flags katalog, centang, kolom, aksi baris, satu-foot), tetapi baris diambil server lewat satuRemoteTable
|
||||
(fetch JSON ke $url), sehingga alamat halaman tidak berubah. Halaman pertama ikut dirender sebagai data awal.
|
||||
columns: [['key', 'label', 'num' => bool, 'badge' => bool]]; kolom badge memakai row.{key} dan nada row.tone.
|
||||
Tombol aksi hanya notifikasi prototipe.
|
||||
--}}
|
||||
@php
|
||||
$tools = [
|
||||
'T' => ['Tambah', 'plus', 'primary', "demo('Tambah')"],
|
||||
'H' => ['Hapus', 'trash', 'danger', 'remove()'],
|
||||
'A' => ['Aksi', 'ellipsis-horizontal-circle', 'secondary', "demo('Aksi')"],
|
||||
'C' => ['Cetak', 'printer', 'secondary', 'window.print()'],
|
||||
];
|
||||
$active = array_filter($tools, fn (string $key): bool => str_contains($page['flags'], $key), ARRAY_FILTER_USE_KEY);
|
||||
$checkbox = in_array('#', $page['columns'], true);
|
||||
$actions = in_array('Aksi', $page['columns'], true);
|
||||
@endphp
|
||||
|
||||
<x-satu.frame :page="$page" :crumbs="$crumbs" :note="$note">
|
||||
@if ($data === null)
|
||||
<x-glass.panel padding="lg">
|
||||
<x-ui.empty :icon="$empty['icon']" :title="$empty['title']" :description="$empty['description']" />
|
||||
</x-glass.panel>
|
||||
@else
|
||||
@php
|
||||
$config = [
|
||||
'url' => $url,
|
||||
'filters' => array_fill_keys(array_column($filters, 'name'), ''),
|
||||
'data' => $data,
|
||||
];
|
||||
@endphp
|
||||
|
||||
<div class="stack" x-data="satuRemoteTable(@js($config))">
|
||||
<x-glass.panel padding="sm" as="section" aria-label="Filter data">
|
||||
<div class="filter-bar">
|
||||
@foreach ($filters as $filter)
|
||||
<x-form.select
|
||||
:name="'filter_'.$filter['name']"
|
||||
:label="$filter['label']"
|
||||
:options="$filter['options']"
|
||||
placeholder=""
|
||||
x-model="values.{{ $filter['name'] }}"
|
||||
x-on:change="search()"
|
||||
/>
|
||||
@endforeach
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
<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="q" x-on:input.debounce.400ms="search()">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="satu-bar__tools">
|
||||
@foreach ($active as [$label, $icon, $variant, $click])
|
||||
<x-ui.button :variant="$variant" :icon="$icon" size="sm" x-on:click="{{ $click }}">{{ $label }}</x-ui.button>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<x-ui.table :label="'Tabel '.Str::lower($page['title'])">
|
||||
<table class="table satu-table" x-bind:aria-busy="loading">
|
||||
<thead>
|
||||
<tr>
|
||||
@if ($checkbox)
|
||||
<th scope="col" class="satu-check"><input type="checkbox" class="check__input" aria-label="Pilih semua baris di halaman ini" x-bind:checked="allPicked" x-on:change="toggleAll()"></th>
|
||||
@endif
|
||||
@foreach ($columns as $column)
|
||||
<th scope="col" @class(['num' => $column['num'] ?? false])>{{ $column['label'] }}</th>
|
||||
@endforeach
|
||||
@if ($actions)
|
||||
<th scope="col" class="table__actions"><span class="visually-hidden">Aksi</span></th>
|
||||
@endif
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<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>
|
||||
@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>
|
||||
@else
|
||||
<td @class(['num' => $column['num'] ?? false, 'table__title' => $loop->first && ! $checkbox])><span x-text="row.{{ $column['key'] }}"></span></td>
|
||||
@endif
|
||||
@endforeach
|
||||
@if ($actions)
|
||||
<td class="table__actions">
|
||||
<x-ui.button variant="ghost" size="sm" icon="eye" :icon-only="true" aria-label="Lihat" x-on:click="demo('Lihat')" />
|
||||
<x-ui.button variant="ghost" size="sm" icon="pencil-square" :icon-only="true" aria-label="Ubah" x-on:click="demo('Ubah')" />
|
||||
<x-ui.button variant="ghost" size="sm" icon="trash" :icon-only="true" aria-label="Hapus" x-on:click="demo('Hapus')" />
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
<p class="satu-empty" x-show="view.length === 0" x-cloak>Tidak ada data yang cocok dengan pencarian atau filter.</p>
|
||||
</x-ui.table>
|
||||
|
||||
<div class="satu-foot">
|
||||
<p class="satu-foot__info" aria-live="polite">Halaman <span x-text="page.toLocaleString('id-ID')"></span> dari <span x-text="pages.toLocaleString('id-ID')"></span> (<span x-text="total.toLocaleString('id-ID')"></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="search()">
|
||||
@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>
|
||||
</div>
|
||||
@endif
|
||||
</x-satu.frame>
|
||||
Reference in New Issue
Block a user