Improve document type cleanup and student import reliability

This commit is contained in:
2026-05-02 10:42:33 +07:00
parent ac22f8b7c8
commit 700c24209d
6 changed files with 345 additions and 40 deletions
+8 -4
View File
@@ -14,15 +14,19 @@ document.addEventListener('DOMContentLoaded', () => {
event.preventDefault();
const entity = form.dataset.entity || 'data ini';
const title = form.dataset.confirmTitle || 'Hapus data?';
const text = form.dataset.confirmText || `Yakin ingin menghapus ${entity}? Tindakan ini tidak bisa dibatalkan.`;
const confirmButtonColor = form.dataset.confirmButtonColor || '#e11d48';
const confirmButtonText = form.dataset.confirmButtonText || 'Ya, hapus';
Swal.fire({
title: 'Hapus data?',
text: `Yakin ingin menghapus ${entity}? Tindakan ini tidak bisa dibatalkan.`,
title,
text,
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#e11d48',
confirmButtonColor,
cancelButtonColor: '#475569',
confirmButtonText: 'Ya, hapus',
confirmButtonText,
cancelButtonText: 'Batal',
reverseButtons: true,
}).then((result) => {
+18 -4
View File
@@ -31,7 +31,13 @@
{{ $documentType->max_file_size_kb ? number_format($documentType->max_file_size_kb / 1024, 2) . ' MB' : 'Default 5 MB' }}
</td>
<td class="px-6 py-4">
<span class="rounded-full bg-indigo-100 px-3 py-1 text-xs font-semibold text-indigo-700">Dokumen: {{ $documentType->student_documents_count }}</span>
<div class="flex flex-col gap-1">
<span class="rounded-full bg-indigo-100 px-3 py-1 text-xs font-semibold text-indigo-700">Aktif: {{ $documentType->student_documents_count }}</span>
@php($trashedDocumentsCount = $documentType->student_documents_with_trashed_count - $documentType->student_documents_count)
@if ($trashedDocumentsCount > 0)
<span class="rounded-full bg-amber-100 px-3 py-1 text-xs font-semibold text-amber-700">Arsip: {{ $trashedDocumentsCount }}</span>
@endif
</div>
</td>
<td class="px-6 py-4">
@if ($documentType->is_required)
@@ -50,16 +56,24 @@
<td class="px-6 py-4">
<div class="flex flex-wrap items-center gap-2">
<a href="{{ route('document-types.edit', $documentType) }}" class="rounded-xl border border-slate-200 px-3 py-2 text-xs font-semibold text-slate-700 transition hover:bg-slate-50">Edit</a>
@if ($documentType->student_documents_count === 0)
@php($trashedDocumentsCount = $documentType->student_documents_with_trashed_count - $documentType->student_documents_count)
@if ($documentType->student_documents_count === 0 && $trashedDocumentsCount === 0)
<form action="{{ route('document-types.destroy', $documentType) }}" method="POST" class="delete-form" data-entity="jenis dokumen {{ $documentType->name }}">
@csrf
@method('DELETE')
<button type="submit" class="rounded-xl border border-rose-200 px-3 py-2 text-xs font-semibold text-rose-600 transition hover:bg-rose-50">Hapus</button>
</form>
@else
<button type="button" disabled class="cursor-not-allowed rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 text-xs font-semibold text-slate-400" title="Tidak bisa dihapus karena masih dipakai data dokumen siswa">
@elseif ($documentType->student_documents_count > 0)
<button type="button" disabled class="cursor-not-allowed rounded-xl border border-slate-200 bg-slate-100 px-3 py-2 text-xs font-semibold text-slate-400" title="Tidak bisa dihapus karena masih dipakai data dokumen siswa aktif">
Dipakai
</button>
@else
<form action="{{ route('document-types.purge-archived-documents', $documentType) }}" method="POST" class="delete-form" data-entity="arsip dokumen untuk jenis dokumen {{ $documentType->name }}" data-confirm-title="Bersihkan arsip dokumen?" data-confirm-text="Arsip dokumen siswa yang terkait akan dihapus permanen, lalu jenis dokumen ini ikut dihapus. Tindakan ini tidak bisa dibatalkan.">
@csrf
<button type="submit" class="rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs font-semibold text-amber-700 transition hover:bg-amber-100">
Bersihkan Arsip
</button>
</form>
@endif
</div>
</td>
+14 -6
View File
@@ -85,14 +85,22 @@
<div class="text-xs text-slate-400">{{ $row['data']['gender'] ?: '-' }} · {{ $row['data']['phone_number'] ?: '-' }}</div>
</td>
<td class="px-4 py-4 text-slate-600">
<div>Tahun: {{ $row['data']['academic_year_id'] ?: '-' }}</div>
<div>Jurusan: {{ $row['data']['department_id'] ?: '-' }}</div>
<div>Kelas: {{ $row['data']['class_id'] ?: '-' }}</div>
<div>Tahun: {{ $row['display']['academic_year'] ?? ($row['data']['academic_year_id'] ?: '-') }}</div>
<div>Jurusan: {{ $row['display']['department'] ?? ($row['data']['department_id'] ?: '-') }}</div>
<div>Kelas: {{ $row['display']['class'] ?? ($row['data']['class_id'] ?: '-') }}</div>
@if (!empty($row['display']['class_context']))
<div class="text-xs text-slate-400">{{ $row['display']['class_context'] }}</div>
@endif
</td>
<td class="px-4 py-4">
<span class="rounded-full px-3 py-1 text-xs font-semibold {{ $row['action'] === 'update' ? 'bg-amber-100 text-amber-700' : 'bg-sky-100 text-sky-700' }}">
{{ $row['action'] === 'update' ? 'Update' : 'Insert' }}
</span>
<div class="flex flex-col gap-2">
<span class="rounded-full px-3 py-1 text-xs font-semibold {{ $row['action'] === 'update' ? 'bg-amber-100 text-amber-700' : 'bg-sky-100 text-sky-700' }}">
{{ $row['action'] === 'update' ? 'Update' : 'Insert' }}
</span>
<span class="rounded-full bg-slate-100 px-3 py-1 text-xs font-semibold text-slate-600">
Status: {{ $row['display']['status'] ?? ($row['data']['status'] ?: '-') }}
</span>
</div>
</td>
<td class="px-4 py-4 text-sm">
@if ($row['is_valid'])