monev sampai target
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<div
|
||||
class="offcanvas offcanvas-end"
|
||||
tabindex="-1"
|
||||
id="offcanvasAddTransformasi"
|
||||
aria-labelledby="offcanvasAddTransformasiLabel">
|
||||
<div class="offcanvas-header border-bottom">
|
||||
<h5 id="offcanvasAddTransformasiLabel" class="offcanvas-title">Tambah Transformasi</h5>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close text-reset"
|
||||
data-bs-dismiss="offcanvas"
|
||||
aria-label="Tutup"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body mx-0 flex-grow-0 p-6 h-100">
|
||||
<form class="add-new-transformasi pt-0" id="addNewTransformasiForm" action="{{ route('framework.transformasi.store', $framework->id) }}" method="POST">
|
||||
@csrf
|
||||
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="add-transformasi-kode">Kode<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="add-transformasi-kode" name="kode" placeholder="Cth: TR1" />
|
||||
</div>
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="add-transformasi-nama">Transformasi<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="add-transformasi-nama" name="nama" placeholder="Cth: Transformasi" />
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success me-3 data-submit">Simpan</button>
|
||||
<button type="reset" class="btn btn-label-danger" data-bs-dismiss="offcanvas">Batal</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
const offcanvasAdd = new bootstrap.Offcanvas(document.getElementById('offcanvasAddTransformasi'));
|
||||
$('#addNewTransformasiForm').validate({
|
||||
rules: {
|
||||
kode: { required: true },
|
||||
nama: { required: true }
|
||||
},
|
||||
messages: {
|
||||
kode: { required: "Kode transformasi wajib diisi" },
|
||||
nama: { required: "Transformasi wajib diisi" }
|
||||
},
|
||||
submitHandler: function (form) {
|
||||
$.ajax({
|
||||
url: $(form).attr('action'),
|
||||
type: 'POST',
|
||||
data: $(form).serialize(),
|
||||
success: function () {
|
||||
offcanvasAdd.hide();
|
||||
form.reset();
|
||||
Swal.fire({ icon: 'success', title: 'Berhasil!', showConfirmButton: false, timer: 1500 })
|
||||
.then(() => window.location.reload());
|
||||
},
|
||||
error: function (xhr) {
|
||||
Swal.fire({ icon: 'error', title: 'Gagal!', text: xhr.responseJSON?.message || 'Error' });
|
||||
}
|
||||
});
|
||||
},
|
||||
errorElement: 'div',
|
||||
errorPlacement: function (error, element) {
|
||||
error.addClass('invalid-feedback');
|
||||
element.closest('.mb-6, .form-control-validation').append(error);
|
||||
},
|
||||
highlight: function (element) {
|
||||
$(element).addClass('is-invalid');
|
||||
},
|
||||
unhighlight: function (element) {
|
||||
$(element).removeClass('is-invalid');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@@ -0,0 +1,97 @@
|
||||
<div
|
||||
class="offcanvas offcanvas-end"
|
||||
tabindex="-1"
|
||||
id="offcanvasUpdateTransformasi"
|
||||
aria-labelledby="offcanvasUpdateTransformasiLabel">
|
||||
<div class="offcanvas-header border-bottom">
|
||||
<h5 id="offcanvasUpdateTransformasiLabel" class="offcanvas-title">Edit Transformasi</h5>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close text-reset"
|
||||
data-bs-dismiss="offcanvas"
|
||||
aria-label="Tutup"></button>
|
||||
</div>
|
||||
<div class="offcanvas-body mx-0 flex-grow-0 p-6 h-100">
|
||||
<form class="update-transformasi pt-0" id="updateTransformasiForm" action="{{ route('framework.transformasi.update', [$framework->id, ':id']) }}" method="POST">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
<input type="hidden" id="update-transformasi-id" name="id" />
|
||||
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="update-transformasi-kode">Kode<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="update-transformasi-kode" name="kode" placeholder="Cth: TR1" />
|
||||
</div>
|
||||
<div class="mb-6 form-control-validation">
|
||||
<label class="form-label" for="update-transformasi-nama">Transformasi<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="update-transformasi-nama" name="nama" placeholder="Cth: Transformasi" />
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success me-3 data-submit">Simpan</button>
|
||||
<button type="reset" class="btn btn-label-danger" data-bs-dismiss="offcanvas">Batal</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
const offcanvasUpdateTransformasi = new bootstrap.Offcanvas(document.getElementById('offcanvasUpdateTransformasi'));
|
||||
$(".edit-transformasi").click(function () {
|
||||
const id = $(this).data('id');
|
||||
console.log('Edit transformasi: ' + id);
|
||||
|
||||
const editForm = $('#updateTransformasiForm');
|
||||
editForm.validate().resetForm();
|
||||
editForm.find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.get("{{ route('framework.transformasi.show', [$framework->id, ':id']) }}".replace(':id', id), function (res) {
|
||||
if (res.status === 'success') {
|
||||
$('#update-transformasi-id').val(res.data.id);
|
||||
$('#update-transformasi-kode').val(res.data.kode);
|
||||
$('#update-transformasi-nama').val(res.data.nama);
|
||||
offcanvasUpdateTransformasi.show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#updateTransformasiForm').validate({
|
||||
rules: {
|
||||
kode: { required: true },
|
||||
nama: { required: true }
|
||||
},
|
||||
messages: {
|
||||
kode: { required: "Kode transformasi wajib diisi" },
|
||||
nama: { required: "Transformasi wajib diisi" }
|
||||
},
|
||||
submitHandler: function (form) {
|
||||
$.ajax({
|
||||
url: $(form).attr('action').replace(':id', $('#update-transformasi-id').val()),
|
||||
type: 'PUT',
|
||||
data: $(form).serialize(),
|
||||
success: function () {
|
||||
offcanvasUpdateTransformasi.hide();
|
||||
form.reset();
|
||||
Swal.fire({ icon: 'success', title: 'Berhasil!', showConfirmButton: false, timer: 1500 })
|
||||
.then(() => window.location.reload());
|
||||
},
|
||||
error: function (xhr) {
|
||||
Swal.fire({ icon: 'error', title: 'Gagal!', text: xhr.responseJSON?.message || 'Error' });
|
||||
}
|
||||
});
|
||||
},
|
||||
errorElement: 'div',
|
||||
errorPlacement: function (error, element) {
|
||||
error.addClass('invalid-feedback');
|
||||
element.closest('.mb-6, .form-control-validation').append(error);
|
||||
},
|
||||
highlight: function (element) {
|
||||
$(element).addClass('is-invalid');
|
||||
},
|
||||
unhighlight: function (element) {
|
||||
$(element).removeClass('is-invalid');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user