Commit awal: prototipe UI SIAKAD Untan
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
@php
|
||||
$editing = $row !== null;
|
||||
$heading = ($editing ? 'Ubah ' : 'Tambah ').Str::lower($names['singular']);
|
||||
@endphp
|
||||
|
||||
<x-layouts.app :title="$heading">
|
||||
<x-ui.page-header
|
||||
:title="$heading"
|
||||
:description="$names['description'] ?? null"
|
||||
:breadcrumbs="[$names['plural'] => route($base.'.index'), $heading => null]"
|
||||
/>
|
||||
|
||||
<form method="POST" action="{{ $action }}" class="stack" novalidate>
|
||||
@csrf
|
||||
@if ($method !== 'POST') @method($method) @endif
|
||||
|
||||
@if ($errors->any())
|
||||
<x-ui.alert tone="danger" title="Data belum dapat disimpan">Periksa isian yang ditandai lalu coba lagi.</x-ui.alert>
|
||||
@endif
|
||||
|
||||
@foreach ($sections as $title => $fields)
|
||||
<x-glass.panel padding="lg">
|
||||
<x-form.section :title="$title" :columns="2">
|
||||
@foreach ($fields as $field)
|
||||
@php
|
||||
$type = $field['type'] ?? 'text';
|
||||
$span = ($field['span'] ?? null) === 'full' || $type === 'textarea' ? 'col-span-full' : null;
|
||||
$attrs = $field['attrs'] ?? [];
|
||||
$required = ! ($field['optional'] ?? false) && in_array('required', (array) ($field['rules'] ?? []), true);
|
||||
@endphp
|
||||
<div @class([$span])>
|
||||
@if ($type === 'select')
|
||||
<x-form.select
|
||||
:name="$field['name']"
|
||||
:label="$field['label']"
|
||||
:options="$field['options']"
|
||||
:value="$field['current']"
|
||||
:placeholder="$field['placeholder'] ?? 'Pilih'"
|
||||
:hint="$field['hint'] ?? null"
|
||||
:optional="$field['optional'] ?? false"
|
||||
:required="$required"
|
||||
/>
|
||||
@elseif ($type === 'textarea')
|
||||
<x-form.textarea
|
||||
:name="$field['name']"
|
||||
:label="$field['label']"
|
||||
:value="$field['current']"
|
||||
:hint="$field['hint'] ?? null"
|
||||
:optional="$field['optional'] ?? false"
|
||||
:required="$required"
|
||||
:rows="$field['rows'] ?? 4"
|
||||
/>
|
||||
@elseif ($type === 'checkbox')
|
||||
<x-form.checkbox
|
||||
:name="$field['name']"
|
||||
:label="$field['label']"
|
||||
:checked="(bool) old($field['name'], $field['current'] ?? ($field['default'] ?? false))"
|
||||
/>
|
||||
@else
|
||||
<x-form.field
|
||||
:name="$field['name']"
|
||||
:label="$field['label']"
|
||||
:type="$type"
|
||||
:value="$field['current']"
|
||||
:hint="$field['hint'] ?? null"
|
||||
:optional="$field['optional'] ?? false"
|
||||
:required="$required"
|
||||
:prefix="$field['prefix'] ?? null"
|
||||
:suffix="$field['suffix'] ?? null"
|
||||
:autocomplete="$type === 'password' ? 'new-password' : 'off'"
|
||||
:placeholder="$field['placeholder'] ?? null"
|
||||
:min="$attrs['min'] ?? null"
|
||||
:max="$attrs['max'] ?? null"
|
||||
:step="$attrs['step'] ?? null"
|
||||
:maxlength="$attrs['maxlength'] ?? null"
|
||||
/>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</x-form.section>
|
||||
</x-glass.panel>
|
||||
@endforeach
|
||||
|
||||
<x-form.actions>
|
||||
<x-ui.button type="submit" icon="check">{{ $editing ? 'Simpan perubahan' : 'Simpan' }}</x-ui.button>
|
||||
<x-ui.button variant="secondary" :href="route($base.'.index')">Batal</x-ui.button>
|
||||
</x-form.actions>
|
||||
</form>
|
||||
</x-layouts.app>
|
||||
@@ -0,0 +1,97 @@
|
||||
<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>
|
||||
@@ -0,0 +1,25 @@
|
||||
<x-layouts.app :title="$heading">
|
||||
<x-ui.page-header
|
||||
:title="$heading"
|
||||
:description="$names['description'] ?? null"
|
||||
:breadcrumbs="[$names['plural'] => route($base.'.index'), $heading => null]"
|
||||
>
|
||||
<x-slot:actions>
|
||||
<x-ui.button variant="secondary" :href="route($base.'.index')" icon="arrow-left">Kembali</x-ui.button>
|
||||
@if ($abilities['edit'])
|
||||
<x-ui.button :href="route($base.'.edit', $keyOf($row))" icon="pencil-square">Ubah</x-ui.button>
|
||||
@endif
|
||||
</x-slot:actions>
|
||||
</x-ui.page-header>
|
||||
|
||||
<x-glass.panel padding="lg">
|
||||
<dl class="ledger">
|
||||
@foreach ($details as $label => $value)
|
||||
<div class="ledger__row">
|
||||
<dt>{{ $label }}</dt>
|
||||
<dd>{{ $value === null || $value === '' ? '-' : $value }}</dd>
|
||||
</div>
|
||||
@endforeach
|
||||
</dl>
|
||||
</x-glass.panel>
|
||||
</x-layouts.app>
|
||||
Reference in New Issue
Block a user