71 lines
5.0 KiB
PHP
71 lines
5.0 KiB
PHP
{{--
|
||
Navigasi bagian + panel biodata (lihat/ubah di tempat) untuk halaman detail operator. Dipakai di dalam elemen ber-x-data
|
||
`bioDetail` (resources/js/app.js). $sections: bagian dari StudentBiodata/EmployeeBiodata (+ opsional `readonly`).
|
||
--}}
|
||
@props(['sections'])
|
||
|
||
<div class="bio">
|
||
<x-glass.panel padding="sm" as="nav" class="bio__nav" aria-label="Bagian biodata">
|
||
<div class="bio__tabs" role="tablist" aria-orientation="vertical">
|
||
@foreach ($sections as $key => $section)
|
||
<button type="button" role="tab" id="bio-tab-{{ $key }}" class="bio__tab" aria-controls="bio-panel-{{ $key }}" data-no-busy
|
||
x-bind:aria-selected="tab === '{{ $key }}'" x-bind:tabindex="tab === '{{ $key }}' ? 0 : -1" x-on:click="show('{{ $key }}')">
|
||
<x-dynamic-component :component="'heroicon-o-'.$section['icon']" />
|
||
<span>{{ $section['title'] }}</span>
|
||
</button>
|
||
@endforeach
|
||
</div>
|
||
</x-glass.panel>
|
||
|
||
<div class="bio__panels">
|
||
@foreach ($sections as $key => $section)
|
||
<x-glass.panel padding="lg" as="section" role="tabpanel" id="bio-panel-{{ $key }}" aria-labelledby="bio-tab-{{ $key }}" x-ref="panel-{{ $key }}" x-show="tab === '{{ $key }}'" x-cloak>
|
||
<div class="bio-head">
|
||
<span class="bio-head__icon" aria-hidden="true"><x-dynamic-component :component="'heroicon-o-'.$section['icon']" /></span>
|
||
<div class="bio-head__text">
|
||
<h2 class="bio-head__title">{{ $section['title'] }}</h2>
|
||
<p class="bio-head__hint">{{ $section['description'] }}</p>
|
||
</div>
|
||
<x-ui.button variant="secondary" size="sm" icon="pencil-square" x-show="editing !== '{{ $key }}'" x-on:click="edit('{{ $key }}')">Ubah</x-ui.button>
|
||
</div>
|
||
|
||
<dl class="bio-list" x-show="editing !== '{{ $key }}'">
|
||
@foreach ($section['readonly'] ?? [] as $item)
|
||
<div class="bio-list__item">
|
||
<dt>{{ $item['label'] }}</dt>
|
||
<dd x-text="display.{{ $key }}.{{ $item['name'] }}" x-bind:class="{ 'bio-list__empty': display.{{ $key }}.{{ $item['name'] }} === '–' }">{{ $section['display'][$item['name']] }}</dd>
|
||
</div>
|
||
@endforeach
|
||
@foreach ($section['fields'] as $field)
|
||
<div @class(['bio-list__item', 'bio-list__item--wide' => $field['wide'] ?? false])>
|
||
<dt>{{ $field['label'] }}</dt>
|
||
<dd x-text="display.{{ $key }}.{{ $field['name'] }}" x-bind:class="{ 'bio-list__empty': display.{{ $key }}.{{ $field['name'] }} === '–' }">{{ $section['display'][$field['name']] }}</dd>
|
||
</div>
|
||
@endforeach
|
||
</dl>
|
||
|
||
<form class="satu-form bio-form" novalidate data-no-busy x-bind:aria-busy="saving" x-show="editing === '{{ $key }}'" x-cloak x-on:submit.prevent="save()" x-on:keydown.escape="cancel()">
|
||
@foreach ($section['fields'] as $field)
|
||
@php
|
||
$type = $field['type'] ?? 'text';
|
||
$id = 'bio_'.$field['name'];
|
||
$wide = ($field['wide'] ?? false) ? 'col-span-full' : null;
|
||
@endphp
|
||
@if ($type === 'select')
|
||
<x-form.select :name="$id" :label="$field['label']" :options="$field['options']" :placeholder="($field['blank'] ?? false) ? '' : null" :required="$field['required'] ?? false" x-model="form.{{ $field['name'] }}" />
|
||
@elseif ($type === 'textarea')
|
||
<x-form.textarea :name="$id" :label="$field['label']" :rows="3" :maxlength="$field['max']" :class="$wide" x-model="form.{{ $field['name'] }}" />
|
||
@else
|
||
<x-form.field :name="$id" :label="$field['label']" :type="$type" :maxlength="$type === 'number' ? null : ($field['max'] ?? null)" :min="$type === 'number' ? ($field['min'] ?? null) : null" :max="$type === 'number' ? ($field['max'] ?? null) : null" :required="$field['required'] ?? false" :placeholder="$field['placeholder'] ?? null" :class="$wide" x-model="form.{{ $field['name'] }}" />
|
||
@endif
|
||
@endforeach
|
||
<div class="satu-form__actions">
|
||
<x-ui.button type="submit" variant="primary" icon="check" x-bind:disabled="saving" x-bind:data-busy="saving ? '' : false" x-bind:aria-busy="saving"><span x-text="saving ? 'Menyimpan...' : 'Simpan'">Simpan</span></x-ui.button>
|
||
<x-ui.button variant="secondary" data-no-busy x-bind:disabled="saving" x-on:click="cancel()">Batal</x-ui.button>
|
||
</div>
|
||
</form>
|
||
</x-glass.panel>
|
||
@endforeach
|
||
</div>
|
||
</div>
|