98 lines
4.1 KiB
PHP
98 lines
4.1 KiB
PHP
<div
|
|
class="offcanvas offcanvas-end"
|
|
tabindex="-1"
|
|
id="offcanvasMoveColumn"
|
|
aria-labelledby="offcanvasMoveColumnLabel">
|
|
<div class="offcanvas-header border-bottom">
|
|
<h5 id="offcanvasMoveColumnLabel" class="offcanvas-title">Edit Kolom</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="pt-0" id="moveColumnForm" action="{{ route('tabel.formulir.update', [$tabel->id, ':id']) }}" method="POST">
|
|
@csrf
|
|
@method('PUT')
|
|
|
|
<input type="hidden" id="move-column-id" name="id" />
|
|
<input type="hidden" id="move-column-tipe" name="tipe" value="form-column" />
|
|
<input type="hidden" id="move-column-width" name="column_width" value="" />
|
|
|
|
<div class="mb-6 form-control-validation">
|
|
<label class="form-label" for="move-column-parent">Row Induk</label>
|
|
<select class="form-select" id="move-column-parent" name="parent_id">
|
|
<option value="">Pilih Row Induk</option>
|
|
@foreach ($tabel->form->where('tipe', \App\Enums\LayoutForm::ROW) as $row)
|
|
<option value="{{ $row->id }}">Row: {{ $row->urutan }}</option>
|
|
@endforeach
|
|
</select>
|
|
</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 offcanvasMoveColumn = new bootstrap.Offcanvas(document.getElementById('offcanvasMoveColumn'));
|
|
$('.move-column').click(function(e) {
|
|
console.log('move column');
|
|
e.preventDefault();
|
|
const id = $(this).data('id');
|
|
$.get("{{ route('tabel.formulir.show', [$tabel->id, ':id']) }}".replace(':id', id), function (res) {
|
|
if (res.status !== 'success') {
|
|
return;
|
|
}
|
|
$('#move-column-id').val(res.data.id);
|
|
$('#move-column-parent').val(res.data.parent_id);
|
|
$('#move-column-width').val(res.data.column_width);
|
|
offcanvasMoveColumn.show();
|
|
}).fail(function (xhr) {
|
|
Swal.fire({ icon: 'error', title: 'Gagal!', text: xhr.responseJSON?.message || 'Error' });
|
|
});
|
|
});
|
|
$('#moveColumnForm').validate({
|
|
rules: {
|
|
parent_id: { required: true },
|
|
},
|
|
messages: {
|
|
parent_id: { required: "Row induk wajib diisi" },
|
|
},
|
|
submitHandler: function (form) {
|
|
console.log($('#move-column-id').val());
|
|
$.ajax({
|
|
url: $(form).attr('action').replace(':id', $('#move-column-id').val()),
|
|
type: 'PUT',
|
|
data: $(form).serialize(),
|
|
success: function () {
|
|
offcanvasMoveColumn.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 |