Commit awal: prototipe UI SIAKAD Untan
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
@php
|
||||
$tools = [
|
||||
'T' => ['Tambah', 'plus', 'primary'],
|
||||
'H' => ['Hapus', 'trash', 'danger'],
|
||||
'A' => ['Aksi', 'ellipsis-horizontal-circle', 'secondary'],
|
||||
'C' => ['Cetak', 'printer', 'secondary'],
|
||||
];
|
||||
$active = array_filter($tools, fn (string $key): bool => str_contains($page['flags'], $key), ARRAY_FILTER_USE_KEY);
|
||||
$payload = [
|
||||
'rows' => collect($rows)->map(fn (array $cells, int $i): array => ['id' => $i, 'cells' => $cells])->all(),
|
||||
'filterCols' => array_column($filters, 'col'),
|
||||
];
|
||||
@endphp
|
||||
|
||||
<x-satu.frame :page="$page" :crumbs="$crumbs">
|
||||
<div class="stack" x-data="satuTable(@js($payload))">
|
||||
@if ($filters)
|
||||
<x-glass.panel padding="sm" as="section" aria-label="Filter data">
|
||||
<div class="filter-bar">
|
||||
@foreach ($filters as $i => $filter)
|
||||
<x-form.select
|
||||
:name="'filter_'.$i"
|
||||
:label="$filter['label']"
|
||||
:options="array_combine($filter['options'], $filter['options'])"
|
||||
placeholder=""
|
||||
x-model="values[{{ $i }}]"
|
||||
x-on:change="reset()"
|
||||
/>
|
||||
@endforeach
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
@endif
|
||||
|
||||
<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">
|
||||
@foreach ($active as $key => [$label, $icon, $variant])
|
||||
@php $click = $key === 'H' ? 'remove()' : "demo('".$label."')"; @endphp
|
||||
<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">
|
||||
<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 ($headers as $h)
|
||||
<th scope="col" @class(['num' => $h['num']])>{{ $h['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 ($headers as $ci => $h)
|
||||
<td @class(['num' => $h['num'], 'table__title' => $loop->first && ! $checkbox])>
|
||||
<span @class(['badge' => $h['badge']]) x-bind:class="row.cells[{{ $ci }}].t ? 'badge--' + row.cells[{{ $ci }}].t : ''" x-text="row.cells[{{ $ci }}].v"></span>
|
||||
</td>
|
||||
@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="filtered.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"></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()">
|
||||
<option value="10">10 data</option>
|
||||
<option value="25">25 data</option>
|
||||
</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>
|
||||
</x-satu.frame>
|
||||
Reference in New Issue
Block a user