[Operator] Perbaikan Halaman Kurikulum

This commit is contained in:
Ariyutta
2026-11-12 16:10:18 +07:00
parent d592630f57
commit 15be51ebd6
13 changed files with 159 additions and 21 deletions
@@ -66,7 +66,7 @@
'form' => $form ? ['withFilters' => $form['withFilters'] ?? [], 'cascades' => collect($form['fields'])->filter(fn (array $f): bool => isset($f['dependsOn']))->map(fn (array $f): array => ['field' => $f['name'], 'parent' => $f['dependsOn'], 'options' => $f['optionsBy'], 'emptyHint' => $f['emptyHint'] ?? null, 'label' => mb_strtolower($f['label']), 'parentLabel' => mb_strtolower((string) collect($form['fields'])->firstWhere('name', $f['dependsOn'])['label'])])->values()->all(), 'storeUrl' => $form['storeUrl'], 'updateUrl' => $form['updateUrl'] ?? null, 'fields' => array_map(fn (array $f): array => ['name' => $f['name'], 'default' => $f['default'] ?? (($f['multiple'] ?? false) ? [] : '')], $form['fields'])] : null,
// Kolom dinamis: kolom awal dari data halaman pertama agar render awal langsung punya kepala dan sel
'columns' => $dynamicColumns
? collect($data['columns'] ?? [])->map(fn (array $c): array => ['key' => $c['key'], 'label' => $c['label'], 'num' => (bool) ($c['num'] ?? false)])->values()->all()
? collect($data['columns'] ?? [])->map(fn (array $c): array => ['key' => $c['key'], 'label' => $c['label'], 'num' => (bool) ($c['num'] ?? false), 'meter' => (bool) ($c['meter'] ?? false)])->values()->all()
: collect($columns)->map(fn (array $c): array => ['key' => $c['key'], 'label' => $c['label']])->values()->all(),
'token' => csrf_token(),
];
@@ -166,7 +166,20 @@
<tr>
@if ($dynamicColumns)
<template x-for="(col, ci) in columns" x-bind:key="col.key">
<td x-bind:class="{ num: col.num, table__title: ci === 0 }" x-text="row[col.key] === null || row[col.key] === undefined || row[col.key] === '' ? '-' : row[col.key]"></td>
<td x-bind:class="{ num: col.num, table__title: ci === 0 }">
{{-- Kolom meter: bar persen (0–100) dengan angkanya --}}
<template x-if="col.meter">
<div class="meter meter--inline" x-bind:class="'meter--scale-' + meterScale(row[col.key])">
<div class="meter__track" role="meter" aria-valuemin="0" aria-valuemax="100" x-bind:aria-valuenow="Number(row[col.key]) || 0" x-bind:aria-valuetext="(Number(row[col.key]) || 0).toLocaleString('id-ID') + '%'">
<div class="meter__fill" x-bind:style="'--meter-ratio: ' + Math.max(0, Math.min(1, (Number(row[col.key]) || 0) / 100))"></div>
</div>
<span class="meter__text" x-text="(Number(row[col.key]) || 0).toLocaleString('id-ID') + '%'"></span>
</div>
</template>
<template x-if="!col.meter">
<span x-text="row[col.key] === null || row[col.key] === undefined || row[col.key] === '' ? '-' : row[col.key]"></span>
</template>
</td>
</template>
@endif
@if ($checkbox)
@@ -258,7 +271,18 @@
@foreach ($detailScalar as $column)
<div>
<dt>{{ $column['label'] }}</dt>
<dd x-text="viewing && viewing.{{ $column['key'] }} !== null && viewing.{{ $column['key'] }} !== '' && viewing.{{ $column['key'] }} !== undefined ? viewing.{{ $column['key'] }} : '-'"></dd>
@if ($column['meter'] ?? false)
<dd>
<div class="meter meter--inline" x-bind:class="'meter--scale-' + meterScale(viewing?.{{ $column['key'] }})">
<div class="meter__track" role="meter" aria-valuemin="0" aria-valuemax="100" x-bind:aria-valuenow="Number(viewing?.{{ $column['key'] }}) || 0" x-bind:aria-valuetext="(Number(viewing?.{{ $column['key'] }}) || 0).toLocaleString('id-ID') + '%'">
<div class="meter__fill" x-bind:style="'--meter-ratio: ' + Math.max(0, Math.min(1, (Number(viewing?.{{ $column['key'] }}) || 0) / 100))"></div>
</div>
<span class="meter__text" x-text="(Number(viewing?.{{ $column['key'] }}) || 0).toLocaleString('id-ID') + '%'"></span>
</div>
</dd>
@else
<dd x-text="viewing && viewing.{{ $column['key'] }} !== null && viewing.{{ $column['key'] }} !== '' && viewing.{{ $column['key'] }} !== undefined ? viewing.{{ $column['key'] }} : '-'"></dd>
@endif
</div>
@endforeach
</div>