Perbaikan menu Operator
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Support\Legacy\AcademicCalendar;
|
||||
use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\Administration;
|
||||
use App\Support\Legacy\Graduation;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -188,7 +189,7 @@ class YudisiumController extends Controller
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page, 'crumbs' => $this->crumbs('ms_periodewisuda', $page),
|
||||
'note' => 'Periode yudisium/wisuda asli (t_periodewisuda) dengan sebaran lulusan program studi yang Anda kelola. Predikat otomatis tidak tercatat; tombol aksi belum mengubah data.',
|
||||
'note' => 'Periode yudisium/wisuda asli (t_periodewisuda) dengan sebaran lulusan program studi yang Anda kelola. Tambah, ubah, dan hapus langsung tersimpan di basis data; periode yang sudah punya lulusan tidak bisa dihapus. Predikat otomatis tidak tercatat.',
|
||||
'empty' => ['icon' => 'calendar', 'title' => 'Belum ada periode yudisium', 'description' => 'Periode tampil setelah tercatat di SIAKAD.'],
|
||||
'url' => route('operator.periode-yudisium.data'),
|
||||
'filters' => [
|
||||
@@ -204,6 +205,91 @@ class YudisiumController extends Controller
|
||||
],
|
||||
'perPage' => Graduation::PER_PAGE,
|
||||
'data' => $this->payload($this->graduation->periods($prodi, $this->periodFilter($request, $prodi), Graduation::PER_PAGE[0])),
|
||||
] + $this->periodForm('periode yudisium'));
|
||||
}
|
||||
|
||||
/** Formulir dan hapus periode (dipakai Periode Yudisium dan Periode Wisuda; keduanya t_periodewisuda). */
|
||||
private function periodForm(string $title): array
|
||||
{
|
||||
return [
|
||||
'form' => [
|
||||
'title' => $title,
|
||||
'storeUrl' => route('operator.periode-yudisium.store'),
|
||||
'updateUrl' => route('operator.periode-yudisium.update', '__ID__'),
|
||||
'fields' => [
|
||||
['name' => 'kode', 'label' => 'Kode periode', 'type' => 'text', 'required' => true, 'max' => 5, 'placeholder' => '20251', 'hint' => 'Tahun + nomor periode, maksimal 5 karakter.'],
|
||||
['name' => 'nama', 'label' => 'Nama periode', 'type' => 'text', 'required' => true, 'max' => 50, 'placeholder' => '2025/2026 Periode I'],
|
||||
['name' => 'tahun', 'label' => 'Tahun', 'type' => 'text', 'max' => 4, 'hint' => 'Kosong = empat angka pertama kode.'],
|
||||
['name' => 'periode_kuliah', 'label' => 'Periode akademik', 'type' => 'select', 'options' => $this->calendar->periods()->all()],
|
||||
['name' => 'buka', 'label' => 'Buka pendaftaran', 'type' => 'date'],
|
||||
['name' => 'tutup', 'label' => 'Tutup pendaftaran', 'type' => 'date'],
|
||||
['name' => 'wisuda', 'label' => 'Tanggal wisuda', 'type' => 'date'],
|
||||
['name' => 'status', 'label' => 'Status periode', 'type' => 'select', 'options' => Graduation::periodStatuses(), 'required' => true, 'default' => '0'],
|
||||
],
|
||||
],
|
||||
'destroyUrl' => route('operator.periode-yudisium.destroy'),
|
||||
'destroy' => ['title' => 'Hapus periode terpilih?', 'message' => 'Periode yang sudah punya lulusan terdaftar akan ditolak.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function periodeStore(Request $request): JsonResponse
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
$input = $this->validatedPeriod($request);
|
||||
|
||||
try {
|
||||
$id = $this->graduation->createPeriod($input);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Periode ditambahkan.', 'id' => $id], 201);
|
||||
}
|
||||
|
||||
public function periodeUpdate(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
$input = $this->validatedPeriod($request);
|
||||
|
||||
try {
|
||||
$this->graduation->updatePeriod($id, $input);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => 'Periode diperbarui.']);
|
||||
}
|
||||
|
||||
/** Hapus satu atau beberapa periode (POST {ids}). */
|
||||
public function periodeDestroy(Request $request): JsonResponse
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'min:1'], 'ids.*' => ['integer']], [], ['ids' => 'periode'])['ids'];
|
||||
|
||||
try {
|
||||
$deleted = $this->graduation->deletePeriods($ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => "{$deleted} periode dihapus."]);
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function validatedPeriod(Request $request): array
|
||||
{
|
||||
return $request->validate([
|
||||
'kode' => ['required', 'string', 'max:5'],
|
||||
'nama' => ['required', 'string', 'max:50'],
|
||||
'tahun' => ['nullable', 'string', 'regex:/^\d{4}$/'],
|
||||
'periode_kuliah' => ['nullable', 'integer'],
|
||||
'buka' => ['nullable', 'date_format:Y-m-d'],
|
||||
'tutup' => ['nullable', 'date_format:Y-m-d', 'after_or_equal:buka'],
|
||||
'wisuda' => ['nullable', 'date_format:Y-m-d'],
|
||||
'status' => ['required', 'string', 'in:'.implode(',', array_keys(Graduation::periodStatuses()))],
|
||||
], [], [
|
||||
'kode' => 'kode periode', 'nama' => 'nama periode', 'tahun' => 'tahun', 'periode_kuliah' => 'periode akademik',
|
||||
'buka' => 'tanggal buka pendaftaran', 'tutup' => 'tanggal tutup pendaftaran', 'wisuda' => 'tanggal wisuda', 'status' => 'status periode',
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -221,7 +307,7 @@ class YudisiumController extends Controller
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page, 'crumbs' => $this->crumbs('list_wisuda', $page),
|
||||
'note' => 'Periode wisuda asli (t_periodewisuda). Periode akademik hanya terisi bila tercatat di DB lama. Tombol aksi belum mengubah data.',
|
||||
'note' => 'Periode wisuda asli (t_periodewisuda, sama dengan Periode Yudisium). Tambah, ubah, dan hapus langsung tersimpan di basis data; periode yang sudah punya lulusan tidak bisa dihapus.',
|
||||
'empty' => ['icon' => 'calendar', 'title' => 'Belum ada periode wisuda', 'description' => 'Periode tampil setelah tercatat di SIAKAD.'],
|
||||
'url' => route('operator.periode-wisuda.data'),
|
||||
'filters' => [],
|
||||
@@ -231,7 +317,7 @@ class YudisiumController extends Controller
|
||||
],
|
||||
'perPage' => Graduation::PER_PAGE,
|
||||
'data' => $this->payload($this->graduation->periods($prodi, ['q' => $this->query($request)], Graduation::PER_PAGE[0])),
|
||||
]);
|
||||
] + $this->periodForm('periode wisuda'));
|
||||
}
|
||||
|
||||
public function wisudaData(Request $request): JsonResponse
|
||||
|
||||
Reference in New Issue
Block a user