Update Pendidikan dan Pelatihan

This commit is contained in:
2026-11-04 13:17:36 +07:00
parent aa91c3fe3f
commit b5b046ed86
4 changed files with 63 additions and 14 deletions
@@ -1,5 +1,7 @@
@extends('layout.main')
@use('App\Enums\PendidikanPelatihan\PelatihanGAP')
@push('style')
<style>
.status-switch-row {
@@ -114,11 +116,18 @@
<div class="row align-items-end">
<div class="col-md-5 mb-3">
<label class="form-label">Jenis Pelatihan</label>
<select class="form-select pelatihan-input jenis-pelatihan-select" name="jenis_pelatihan">
<option value="">Pilih Jenis Pelatihan</option>
@foreach (PelatihanGAP::options() as $option)
<option value="{{ $option['value'] }}">{{ $option['label'] }}</option>
@endforeach
</select>
<input
type="text"
class="form-control pelatihan-input"
name="jenis_pelatihan"
placeholder="Contoh: Pelatihan GAP">
class="form-control pelatihan-input jenis-pelatihan-lainnya mt-2 d-none"
name="jenis_pelatihan_lainnya"
placeholder="Sebutkan jenis pelatihan lainnya..."
disabled>
</div>
<div class="col-md-4 mb-3">
@@ -383,14 +392,15 @@ $(function () {
return $form.find('[data-repeater-item]');
}
// Input yang nonaktif (mis. isian "Lainnya" yang tersembunyi) tidak ikut dihitung
function rowAdaIsi($row) {
return $row.find(config.inputSelector).toArray().some(function (input) {
return $row.find(config.inputSelector).not(':disabled').toArray().some(function (input) {
return String($(input).val() || '').trim() !== '';
});
}
function rowLengkap($row) {
const $inputs = $row.find(config.inputSelector);
const $inputs = $row.find(config.inputSelector).not(':disabled');
if ($inputs.length === 0) {
return false;
@@ -453,6 +463,10 @@ $(function () {
$row.find(config.switchSelector).prop('checked', false);
}
if (typeof config.onShow === 'function') {
config.onShow($row);
}
updateAllSwitchText();
$row.slideDown();
@@ -510,7 +524,27 @@ $(function () {
addButtonSelector: '#btn-tambah-pelatihan',
inputSelector: '.pelatihan-input',
deleteButtonSelector: '.btn-delete-pelatihan',
deleteTitle: 'Hapus baris pelatihan ini?'
deleteTitle: 'Hapus baris pelatihan ini?',
onShow: function ($row) {
toggleJenisPelatihanLainnya($row.find('.jenis-pelatihan-select'));
}
});
// Isian bebas hanya muncul jika jenis pelatihan "Lainnya"
function toggleJenisPelatihanLainnya($select) {
const $lainnya = $select.closest('[data-repeater-item]').find('.jenis-pelatihan-lainnya');
const isLainnya = $select.val() === @json(PelatihanGAP::LAINNYA->value);
$lainnya.toggleClass('d-none', !isLainnya).prop('disabled', !isLainnya);
if (!isLainnya) {
$lainnya.val('');
}
}
$(document).on('change', '.form-repeater-pelatihan .jenis-pelatihan-select', function () {
toggleJenisPelatihanLainnya($(this));
$(this).closest('[data-repeater-item]').find('.jenis-pelatihan-lainnya:not(:disabled)').trigger('focus');
});
initRepeaterWithValidation({