Update komoditas Utama
This commit is contained in:
@@ -147,6 +147,18 @@
|
||||
$('#edit-id').val(res.data.id);
|
||||
$('#edit-nama').val(res.data.nama);
|
||||
$('#edit-kode').val(res.data.kode);
|
||||
|
||||
const isUtama =
|
||||
res.data.is_utama === true ||
|
||||
res.data.is_utama === 1 ||
|
||||
res.data.is_utama === '1';
|
||||
|
||||
$('#edit-is-utama').prop('checked', isUtama);
|
||||
|
||||
$('#edit-is-utama-label').text(
|
||||
isUtama ? 'Komoditas Utama' : 'Tidak Termasuk'
|
||||
);
|
||||
|
||||
if (typeof fvEdit !== 'undefined') fvEdit.resetForm();
|
||||
offcanvasEdit.show();
|
||||
}
|
||||
@@ -170,6 +182,14 @@
|
||||
if (res.status === 'success') {
|
||||
$('#view-nama').val(res.data.nama);
|
||||
$('#view-kode').val(res.data.kode);
|
||||
const isUtama =
|
||||
res.data.is_utama === true ||
|
||||
res.data.is_utama === 1 ||
|
||||
res.data.is_utama === '1';
|
||||
|
||||
$('#view-is-utama').val(
|
||||
isUtama ? 'Komoditas Utama' : 'Tidak Termasuk'
|
||||
);
|
||||
offcanvasView.show();
|
||||
}
|
||||
}).fail((xhr) => {
|
||||
@@ -181,7 +201,9 @@
|
||||
|
||||
const editForm = document.getElementById('editKomoditasForm');
|
||||
let fvEdit = FormValidation.formValidation(editForm, {
|
||||
fields: { nama: { validators: { notEmpty: { message: 'Nama komoditas wajib diisi' } } } },
|
||||
fields: { nama: { validators: { notEmpty: { message: 'Nama komoditas wajib diisi' } } } ,
|
||||
kode: {validators: { notEmpty: { message: 'Kode komoditas wajib diisi' } } }
|
||||
},
|
||||
plugins: {
|
||||
trigger: new FormValidation.plugins.Trigger(),
|
||||
bootstrap5: new FormValidation.plugins.Bootstrap5({ eleValidClass: '', rowSelector: '.form-control-validation' }),
|
||||
@@ -249,5 +271,20 @@
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const switchInput = document.getElementById('add-is-utama');
|
||||
const switchLabel = document.getElementById('add-is-utama-label');
|
||||
|
||||
function updateKomoditasLabel() {
|
||||
switchLabel.textContent = switchInput.checked
|
||||
? 'Komoditas Utama'
|
||||
: 'Tidak Termasuk';
|
||||
}
|
||||
|
||||
switchInput.addEventListener('change', updateKomoditasLabel);
|
||||
|
||||
updateKomoditasLabel();
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user