Penambahan Akses Laman Dosen dab perbaikan fix
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
{{-- Daftar berformat SATU dengan paginasi server (untuk data yang barisnya mahal dihitung): filter, cari, dan halaman lewat GET. --}}
|
||||
@php
|
||||
$query = request()->query('q');
|
||||
$query = is_string($query) ? $query : '';
|
||||
$last = $rows->lastPage();
|
||||
$current = $rows->currentPage();
|
||||
$start = max(1, min($current - 2, $last - 4));
|
||||
$window = range($start, $start + min(5, $last) - 1);
|
||||
$per = $rows->perPage();
|
||||
@endphp
|
||||
|
||||
<x-layouts.app :title="$names['plural']">
|
||||
<x-ui.page-header
|
||||
:title="$names['plural']"
|
||||
:description="$names['description'] ?? null"
|
||||
/>
|
||||
|
||||
{{-- Kontrol memakai atribut form="satu-form" agar tabel (dengan tautan dan formulir aksi) tidak berada di dalam formulir pencarian. --}}
|
||||
<div class="stack" x-data x-on:change="$refs.satuForm.requestSubmit()">
|
||||
<form id="satu-form" x-ref="satuForm" method="GET" action="{{ url()->current() }}" role="search" aria-label="Pencarian dan filter"></form>
|
||||
|
||||
@if ($filters)
|
||||
<x-glass.panel padding="sm" as="section" aria-label="Filter data">
|
||||
<div class="filter-bar">
|
||||
@foreach ($filters as $filter)
|
||||
<x-form.select
|
||||
:name="$filter['name']"
|
||||
:label="$filter['label']"
|
||||
:options="$filter['options']"
|
||||
:value="request($filter['name'])"
|
||||
placeholder=""
|
||||
:id="'filter-'.$filter['name']"
|
||||
form="satu-form"
|
||||
/>
|
||||
@endforeach
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
@endif
|
||||
|
||||
<x-glass.panel padding="none" as="section" :aria-label="'Daftar '.Str::lower($names['plural'])">
|
||||
<div class="satu-bar">
|
||||
@if ($searchable)
|
||||
<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" name="q" form="satu-form" value="{{ $query }}" class="field__input" style="--pad-start: 2.5rem" placeholder="Cari {{ Str::lower($names['plural']) }}" autocomplete="off" enterkeyhint="search">
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<x-ui.table :label="'Tabel '.Str::lower($names['plural'])">
|
||||
<table class="table satu-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@foreach ($columns as $col)
|
||||
<th scope="col" @class(['num' => ($col['class'] ?? null) === 'num'])>{{ $col['label'] }}</th>
|
||||
@endforeach
|
||||
<th scope="col" class="table__actions"><span class="visually-hidden">Aksi</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($rows as $row)
|
||||
@php $id = $keyOf($row); @endphp
|
||||
<tr>
|
||||
@foreach ($columns as $col)
|
||||
@php
|
||||
$val = isset($col['value']) ? $col['value']($row) : data_get($row, $col['key']);
|
||||
$tone = isset($col['badge']) ? $col['badge']($row) : null;
|
||||
@endphp
|
||||
<td @class(['num' => ($col['class'] ?? null) === 'num', 'table__title' => $loop->first])>
|
||||
@if ($tone !== null && $val !== null && $val !== '')
|
||||
<x-ui.badge :tone="$tone">{{ $val }}</x-ui.badge>
|
||||
@else
|
||||
{{ $val === null || $val === '' ? '-' : $val }}
|
||||
@endif
|
||||
</td>
|
||||
@endforeach
|
||||
<td class="table__actions">
|
||||
@foreach ($rowActions($row) as $action)
|
||||
<x-ui.button variant="ghost" size="sm" :href="$action['href']" :icon="$action['icon'] ?? null">{{ $action['label'] }}</x-ui.button>
|
||||
@endforeach
|
||||
@if ($abilities['show'])
|
||||
<x-ui.button variant="ghost" size="sm" :href="route($base.'.show', $id)" icon="eye" :icon-only="true" :aria-label="'Lihat '.Str::lower($names['singular'])" />
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@if ($rows->isEmpty())
|
||||
<p class="satu-empty">{{ request()->query() ? 'Tidak ada data yang cocok dengan pencarian atau filter.' : 'Belum ada data '.Str::lower($names['plural']).'.' }}</p>
|
||||
@endif
|
||||
</x-ui.table>
|
||||
|
||||
<div class="satu-foot">
|
||||
<p class="satu-foot__info" aria-live="polite">Halaman {{ $current }} dari {{ $last }} ({{ $rows->total() }} data)</p>
|
||||
|
||||
<label class="satu-foot__per">
|
||||
<span class="visually-hidden">Jumlah data per halaman</span>
|
||||
<select name="per" form="satu-form" class="field__input field__select" data-no-clear>
|
||||
<option value="10" @selected($per === 10)>10 data</option>
|
||||
<option value="25" @selected($per === 25)>25 data</option>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<nav class="satu-pager" aria-label="Halaman data">
|
||||
@if ($current > 1)
|
||||
<a class="satu-pager__btn" href="{{ $rows->url($current - 1) }}" aria-label="Halaman sebelumnya"><x-heroicon-m-chevron-left /></a>
|
||||
@else
|
||||
<span class="satu-pager__btn" aria-hidden="true" style="opacity: 0.4"><x-heroicon-m-chevron-left /></span>
|
||||
@endif
|
||||
@foreach ($window as $n)
|
||||
<a class="satu-pager__btn" href="{{ $rows->url($n) }}" @if ($n === $current) aria-current="page" @endif>{{ $n }}</a>
|
||||
@endforeach
|
||||
@if ($current < $last)
|
||||
<a class="satu-pager__btn" href="{{ $rows->url($current + 1) }}" aria-label="Halaman berikutnya"><x-heroicon-m-chevron-right /></a>
|
||||
@else
|
||||
<span class="satu-pager__btn" aria-hidden="true" style="opacity: 0.4"><x-heroicon-m-chevron-right /></span>
|
||||
@endif
|
||||
</nav>
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
Reference in New Issue
Block a user