[Operator] Perbaikan Laman Portal -> Mahasiswa
This commit is contained in:
@@ -1 +1,77 @@
|
||||
/* Gaya halaman khusus peran operator. Tambahkan hanya kelas yang tidak bisa dibuat dari komponen dan token; semua warna lewat token. */
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
Detail mahasiswa (operator/satu/mahasiswa-detail)
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
.bio-hero { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-md) var(--space-lg); }
|
||||
.bio-hero__id { display: grid; gap: var(--space-3xs); flex: 1 1 16rem; min-width: 0; }
|
||||
.bio-hero__name { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
|
||||
.bio-hero__nim { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--color-ink-2); }
|
||||
.bio-hero__prodi { margin: 0; color: var(--color-muted); }
|
||||
|
||||
/* Navigasi bagian: deret mendatar yang bisa digulir di kontainer sempit, kolom tegak di kontainer lebar */
|
||||
.bio { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-md); align-items: start; min-width: 0; }
|
||||
.bio__panels { display: grid; gap: var(--space-md); min-width: 0; }
|
||||
.bio__tabs { display: flex; gap: var(--space-2xs); overflow-x: auto; scrollbar-width: none; }
|
||||
.bio__tabs::-webkit-scrollbar { display: none; }
|
||||
.bio__tab {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 0 0 auto;
|
||||
gap: var(--space-xs);
|
||||
min-height: 2.75rem;
|
||||
padding-inline: var(--space-sm);
|
||||
border: 0;
|
||||
border-radius: var(--radius-control);
|
||||
background: transparent;
|
||||
color: var(--color-ink-2);
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
text-align: start;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
.bio__tab svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
|
||||
.bio__tab[aria-selected="true"] { background: var(--color-accent-soft); color: var(--color-accent-text); }
|
||||
.bio__tab:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
|
||||
@media (hover: hover) {
|
||||
.bio__tab[aria-selected="false"]:hover { background: color-mix(in oklab, var(--color-ink) 6%, transparent); color: var(--color-ink); }
|
||||
}
|
||||
@container (width >= 56rem) {
|
||||
.bio { grid-template-columns: 15rem minmax(0, 1fr); }
|
||||
.bio__nav { position: sticky; inset-block-start: var(--space-md); }
|
||||
.bio__tabs { flex-direction: column; overflow: visible; }
|
||||
.bio__tab { flex: 1 1 auto; }
|
||||
}
|
||||
|
||||
/* Kepala bagian: ikon, judul, petunjuk, tombol Ubah */
|
||||
.bio-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm) var(--space-md); margin-block-end: var(--space-md); }
|
||||
.bio-head__icon {
|
||||
display: grid;
|
||||
flex-shrink: 0;
|
||||
place-items: center;
|
||||
width: 2.75rem;
|
||||
height: 2.75rem;
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--color-accent-soft);
|
||||
color: var(--color-accent-text);
|
||||
}
|
||||
.bio-head__icon svg { width: 1.375rem; height: 1.375rem; }
|
||||
.bio-head__text { display: grid; gap: var(--space-3xs); flex: 1 1 14rem; min-width: 0; }
|
||||
.bio-head__title { font-size: var(--text-title); }
|
||||
.bio-head__hint { margin: 0; color: var(--color-muted); font-size: var(--text-sm); }
|
||||
|
||||
/* Tampilan baca: pasangan label dan nilai dengan garis tipis */
|
||||
.bio-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 0 var(--space-lg); margin: 0; }
|
||||
.bio-list__item { display: grid; align-content: start; gap: var(--space-3xs); min-width: 0; padding-block: var(--space-sm); border-block-start: var(--rule-hair) solid var(--color-rule); }
|
||||
.bio-list__item--wide { grid-column: 1 / -1; }
|
||||
.bio-list dt { color: var(--color-muted); font-size: var(--text-sm); }
|
||||
.bio-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; white-space: pre-line; }
|
||||
.bio-list .bio-list__empty { color: var(--color-muted); font-weight: 400; }
|
||||
|
||||
/* Formulir ubah: grid kolom otomatis, bantuan hanya muncul saat ada galat (aturan .satu-form) */
|
||||
.bio-form { padding-block-start: var(--space-xs); }
|
||||
/* Saat menyimpan: isian meredup dan tidak bisa diklik; tombol Simpan menampilkan pemintal (aturan .btn[data-busy]) */
|
||||
.bio-form[aria-busy="true"] .field { opacity: 0.6; pointer-events: none; }
|
||||
.bio-form[aria-busy="true"] { cursor: progress; }
|
||||
|
||||
@@ -1047,6 +1047,82 @@ Alpine.data('satuRemoteTable', (config) => ({
|
||||
},
|
||||
}));
|
||||
|
||||
/*
|
||||
* Detail mahasiswa (Portal operator > Mahasiswa): biodata per bagian yang bisa diubah di tempat. Tiap bagian punya nilai
|
||||
* isian (values) dan teks tampil (display); Simpan mengirim PUT JSON untuk satu bagian lalu memakai nilai segar dari server.
|
||||
* config: { tab, saveUrl ("__SECTION__"), token, values: { bagian: { kolom: nilai } }, display: { bagian: { kolom: teks } } }.
|
||||
*/
|
||||
Alpine.data('studentBiodata', (config) => ({
|
||||
tab: config.tab,
|
||||
values: config.values,
|
||||
display: config.display,
|
||||
editing: null,
|
||||
form: {},
|
||||
saving: false,
|
||||
reloading: false,
|
||||
|
||||
get nama() {
|
||||
return this.display.pribadi?.nama ?? '';
|
||||
},
|
||||
|
||||
// Inisial seperti ui.avatar: gelar bertitik dan bagian setelah koma dilewati
|
||||
get initials() {
|
||||
const words = this.nama.split(',')[0].trim().split(/\s+/).filter(Boolean);
|
||||
const plain = words.filter((word) => !word.endsWith('.'));
|
||||
const use = plain.length ? plain : words;
|
||||
return ((use[0]?.[0] ?? '?') + (use.length > 1 ? use[use.length - 1][0] : '')).toUpperCase();
|
||||
},
|
||||
|
||||
show(key) {
|
||||
this.tab = key;
|
||||
},
|
||||
|
||||
edit(key) {
|
||||
this.tab = key;
|
||||
this.editing = key;
|
||||
this.form = { ...this.values[key] };
|
||||
this.$nextTick(() => this.$refs['panel-' + key]?.querySelector('input:not([type=hidden]), select, textarea')?.focus());
|
||||
},
|
||||
|
||||
cancel() {
|
||||
this.editing = null;
|
||||
},
|
||||
|
||||
async save() {
|
||||
const key = this.editing;
|
||||
if (key === null || this.saving) return;
|
||||
const url = config.saveUrl.replace('__SECTION__', encodeURIComponent(key));
|
||||
this.saving = true;
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json', 'X-CSRF-TOKEN': config.token, 'X-Requested-With': 'XMLHttpRequest' },
|
||||
body: JSON.stringify(this.form),
|
||||
});
|
||||
const data = await response.json().catch(() => null);
|
||||
if (!response.ok) {
|
||||
const first = data?.errors ? Object.values(data.errors).flat()[0] : null;
|
||||
throw new Error(first || data?.message || 'Biodata tidak dapat disimpan. Muat ulang halaman lalu coba lagi.');
|
||||
}
|
||||
console.info(`[SIAKAD] PUT ${url}`, { hasil: data.message });
|
||||
// Data akademik mengubah ringkasan di atas halaman: muat ulang (pesan tampil lewat sesi); tombol tetap sibuk
|
||||
if (data.reload) {
|
||||
this.reloading = true;
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
this.values[key] = data.values;
|
||||
this.display[key] = data.display;
|
||||
this.editing = null;
|
||||
window.toast('success', data.message);
|
||||
} catch (error) {
|
||||
window.toast('danger', error.message);
|
||||
} finally {
|
||||
if (!this.reloading) this.saving = false;
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
/*
|
||||
* Kegiatan Akademik (Portal operator, akun DB lama): tabel jenis kegiatan dengan tambah/ubah sebaris dan hapus
|
||||
* berdialog. Baris disaring dan dihalamankan di sisi klien (jumlahnya puluhan); setiap simpan mengirim JSON dan
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
{{--
|
||||
Detail mahasiswa (akun DB lama): ringkasan akademik + biodata dan data akademik per bagian yang bisa diubah di tempat.
|
||||
Dibuka dari aksi Lihat di Portal > Mahasiswa; satu-satunya tempat mengubah data mahasiswa. Bagian biodata diatur
|
||||
StudentBiodata::sections(); bagian akademik dibangun StudentDetailController::academic() dan ditulis StudentRecords.
|
||||
--}}
|
||||
@php
|
||||
$config = [
|
||||
'tab' => 'pribadi',
|
||||
'saveUrl' => $saveUrl,
|
||||
'token' => csrf_token(),
|
||||
'values' => collect($sections)->map(fn (array $s): array => $s['values'])->all(),
|
||||
'display' => collect($sections)->map(fn (array $s): array => $s['display'])->all(),
|
||||
];
|
||||
@endphp
|
||||
|
||||
<x-layouts.app :title="'Mahasiswa '.$student['nama']">
|
||||
<x-ui.page-header title="Detail Mahasiswa" description="Biodata lengkap mahasiswa. Pilih bagian biodata, lalu ubah langsung di halaman ini." :breadcrumbs="$crumbs">
|
||||
<x-slot:actions>
|
||||
<x-ui.button variant="secondary" size="sm" :href="$back" icon="arrow-left">Kembali ke daftar</x-ui.button>
|
||||
</x-slot:actions>
|
||||
</x-ui.page-header>
|
||||
|
||||
<div class="stack" x-data="studentBiodata(@js($config))">
|
||||
<x-glass.panel padding="lg" as="section" aria-labelledby="mhs-nama">
|
||||
<div class="bio-hero">
|
||||
<span class="avatar avatar--xl" role="img" x-bind:aria-label="nama" x-text="initials">{{ \Illuminate\Support\Str::of($student['nama'])->before(',')->squish()->substr(0, 1)->upper() }}</span>
|
||||
<div class="bio-hero__id">
|
||||
<h2 id="mhs-nama" class="bio-hero__name" x-text="nama">{{ $student['nama'] }}</h2>
|
||||
<p class="bio-hero__nim">{{ $student['nim'] }}</p>
|
||||
<p class="bio-hero__prodi">{{ $student['jenjang'] ? $student['jenjang'].' ' : '' }}{{ $student['prodi'] }}</p>
|
||||
</div>
|
||||
<div class="cluster cluster--sm">
|
||||
<x-ui.badge :tone="$student['status']['tone'] === 'neutral' ? 'neutral' : $student['status']['tone']">{{ $student['status']['label'] }}</x-ui.badge>
|
||||
@if ($student['angkatan'])
|
||||
<x-ui.badge tone="accent">Angkatan {{ $student['angkatan'] }}</x-ui.badge>
|
||||
@endif
|
||||
@if ($student['program'])
|
||||
<x-ui.badge>{{ $student['program'] }}</x-ui.badge>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</x-glass.panel>
|
||||
|
||||
<x-ui.figures label="Capaian akademik">
|
||||
<x-ui.figure label="Semester" :value="$student['semester'] !== null ? (int) $student['semester'] : '–'" hint="Semester berjalan" />
|
||||
<x-ui.figure label="SKS lulus" :value="(int) $student['sks_lulus']" hint="Dari transkrip" />
|
||||
<x-ui.figure label="IPK" :value="$student['ipk'] === null ? '–' : number_format($student['ipk'], 2, ',', '')" hint="Indeks prestasi kumulatif" />
|
||||
</x-ui.figures>
|
||||
|
||||
<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']" :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" :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>
|
||||
</div>
|
||||
</x-layouts.app>
|
||||
@@ -4,7 +4,8 @@
|
||||
(fetch JSON ke $url), sehingga alamat halaman tidak berubah. Halaman pertama ikut dirender sebagai data awal.
|
||||
columns: [['key', 'label', 'num' => bool, 'badge' => bool]]; kolom badge memakai row.{key} dan nada row.tone.
|
||||
filters: [['name', 'label', 'options' => [], 'value' => bawaan]] atau ['name', 'label', 'type' => 'check'].
|
||||
Opsional: $viewUrl (aksi Lihat, "__ID__" diganti row.id), $destroyUrl + $destroy['title'|'message'] (Hapus sungguhan
|
||||
Opsional: $tools (kunci tombol bilah yang boleh tampil, [] = tanpa tombol), $selectable (false = tanpa kotak centang),
|
||||
$viewUrl (aksi Lihat, "__ID__" diganti row.id), $destroyUrl + $destroy['title'|'message'] (Hapus sungguhan
|
||||
lewat POST {ids}); $form = ['title', 'storeUrl', 'updateUrl' ("__ID__"), 'fields' => [['name', 'label', 'type' =>
|
||||
text|number|date|select, 'options', 'required', 'max', 'min', 'hint', 'multiple', 'default']]] untuk Tambah/Ubah lewat
|
||||
modal (baris data menyediakan row.form = nilai isian). Hanya tombol yang sungguh bekerja yang ditampilkan; Lihat tanpa
|
||||
@@ -14,15 +15,18 @@
|
||||
$viewUrl ??= null;
|
||||
$destroyUrl ??= null;
|
||||
$form ??= null;
|
||||
$selectable ??= true;
|
||||
$destroy = ($destroy ?? []) + ['title' => 'Hapus data terpilih?', 'message' => 'Data yang dipilih akan dihapus.'];
|
||||
$tools = [
|
||||
$allTools = [
|
||||
'T' => ['Tambah', 'plus', 'primary', 'startInsert()'],
|
||||
'H' => ['Hapus', 'trash', 'danger', 'remove()'],
|
||||
'C' => ['Cetak', 'printer', 'secondary', 'window.print()'],
|
||||
];
|
||||
$active = array_filter($tools, fn (string $key): bool => str_contains($page['flags'], $key)
|
||||
// $tools (opsional): daftar kunci tombol yang boleh tampil (T, H, C); kosong = tanpa tombol. Bawaan: menurut flags katalog.
|
||||
$allowed = isset($tools) ? array_flip($tools) : $allTools;
|
||||
$active = array_filter($allTools, fn (string $key): bool => isset($allowed[$key]) && str_contains($page['flags'], $key)
|
||||
&& match ($key) { 'T' => (bool) $form, 'H' => (bool) $destroyUrl, default => true }, ARRAY_FILTER_USE_KEY);
|
||||
$checkbox = in_array('#', $page['columns'], true);
|
||||
$checkbox = $selectable && in_array('#', $page['columns'], true);
|
||||
$actions = in_array('Aksi', $page['columns'], true);
|
||||
@endphp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user