98 lines
5.5 KiB
PHP
98 lines
5.5 KiB
PHP
<x-layouts.app :title="$names['plural']">
|
|
<x-ui.page-header
|
|
:title="$names['plural']"
|
|
:description="$names['description'] ?? null"
|
|
>
|
|
@if ($abilities['create'])
|
|
<x-slot:actions>
|
|
<x-ui.button :href="route($base.'.create')" icon="plus">Tambah {{ Str::lower($names['singular']) }}</x-ui.button>
|
|
</x-slot:actions>
|
|
@endif
|
|
</x-ui.page-header>
|
|
|
|
<div class="stack">
|
|
@if ($searchable || $filters)
|
|
<x-glass.panel padding="sm">
|
|
<x-ui.filter-bar :search="$searchable" :placeholder="'Cari '.Str::lower($names['plural'])">
|
|
@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']"
|
|
/>
|
|
@endforeach
|
|
</x-ui.filter-bar>
|
|
</x-glass.panel>
|
|
@endif
|
|
|
|
<x-glass.panel padding="none">
|
|
@if ($rows->isEmpty())
|
|
<x-ui.empty icon="inbox" :title="'Tidak ada data '.Str::lower($names['plural'])" :description="request()->query() ? 'Tidak ada hasil untuk pencarian atau filter ini.' : 'Data akan tampil di sini setelah ditambahkan.'" />
|
|
@else
|
|
<x-ui.table :label="'Daftar '.Str::lower($names['plural'])">
|
|
<table class="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
|
|
@if ($abilities['edit'])
|
|
<x-ui.button variant="ghost" size="sm" :href="route($base.'.edit', $id)" icon="pencil-square" :icon-only="true" :aria-label="'Ubah '.Str::lower($names['singular'])" />
|
|
@endif
|
|
@if ($abilities['delete'])
|
|
<x-ui.confirm
|
|
class="inline-flex"
|
|
:action="route($base.'.destroy', $id)"
|
|
method="DELETE"
|
|
:title="'Hapus '.Str::lower($names['singular']).'?'"
|
|
message="Tindakan ini tidak dapat dibatalkan."
|
|
confirm-label="Ya, hapus"
|
|
tone="danger"
|
|
icon="trash"
|
|
:icon-only="true"
|
|
:label="'Hapus '.Str::lower($names['singular'])"
|
|
/>
|
|
@endif
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</x-ui.table>
|
|
@endif
|
|
</x-glass.panel>
|
|
|
|
{{ $rows->links() }}
|
|
</div>
|
|
</x-layouts.app>
|