first commit
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumb')
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Manajemen</a></li>
|
||||
<li class="breadcrumb-item"><a href="javascript:void(0);">Limit</a></li>
|
||||
<li class="breadcrumb-item active" aria-current="page">{{ $title }}</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card border">
|
||||
<div class="card-body">
|
||||
@include('components.datatable-header', [
|
||||
'title' => 'Daftar Limit Penunjang',
|
||||
'description' => 'Berikut adalah daftar limit untuk setiap kategori rubrik penunjang'
|
||||
])
|
||||
|
||||
<table id="table-penunjang" class="table table-bordered table-striped dt-responsive nowrap w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Kategori Rubrik</th>
|
||||
<th>Limit</th>
|
||||
@if($canUbah)
|
||||
<th>Aksi</th>
|
||||
@endif
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Edit -->
|
||||
<div class="modal fade" id="modalEdit" tabindex="-1" aria-labelledby="modalEditLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="modalEditLabel">Edit Limit Penunjang</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<form id="formEdit">
|
||||
<div class="modal-body">
|
||||
<input type="hidden" id="kategori_id" name="kategori_id">
|
||||
<div class="mb-3">
|
||||
<label for="kategori_nama" class="form-label">Kategori Rubrik</label>
|
||||
<input type="text" class="form-control" id="kategori_nama" readonly>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="limit" class="form-label">Limit</label>
|
||||
<input type="number" class="form-control" id="limit" name="limit" min="0" placeholder="Kosongkan untuk null">
|
||||
<small class="form-text text-muted">Kosongkan field ini jika ingin set null</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
||||
<button type="submit" class="btn btn-primary">Simpan</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('js')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var table = $('#table-penunjang').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: "{{ route('manajemen.limit.penunjang.data') }}",
|
||||
columns: [
|
||||
{
|
||||
data: 'DT_RowIndex',
|
||||
name: 'DT_RowIndex',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center'
|
||||
},
|
||||
{
|
||||
data: 'kategori_rubrik',
|
||||
name: 'nama'
|
||||
},
|
||||
{
|
||||
data: 'limit',
|
||||
name: 'limit',
|
||||
className: 'text-center'
|
||||
},
|
||||
@if($canUbah)
|
||||
{
|
||||
data: 'aksi',
|
||||
name: 'aksi',
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
className: 'text-center'
|
||||
}
|
||||
@endif
|
||||
]
|
||||
});
|
||||
|
||||
// Handle Edit Button
|
||||
$('#table-penunjang').on('click', '.btn-edit', function() {
|
||||
var id = $(this).data('id');
|
||||
var nama = $(this).data('nama');
|
||||
var limit = $(this).data('limit');
|
||||
|
||||
$('#kategori_id').val(id);
|
||||
$('#kategori_nama').val(nama);
|
||||
$('#limit').val(limit);
|
||||
$('#modalEdit').modal('show');
|
||||
});
|
||||
|
||||
// Handle Form Submit
|
||||
$('#formEdit').on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var id = $('#kategori_id').val();
|
||||
var limit = $('#limit').val();
|
||||
|
||||
// Convert empty string to null
|
||||
if (limit === '') {
|
||||
limit = null;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('manajemen.limit.penunjang.update', ':id') }}".replace(':id', id),
|
||||
type: 'PUT',
|
||||
data: {
|
||||
_token: "{{ csrf_token() }}",
|
||||
limit: limit
|
||||
},
|
||||
success: function(response) {
|
||||
$('#modalEdit').modal('hide');
|
||||
table.ajax.reload();
|
||||
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
text: response.message,
|
||||
showConfirmButton: false,
|
||||
timer: 1500
|
||||
});
|
||||
},
|
||||
error: function(xhr) {
|
||||
var errors = xhr.responseJSON.errors;
|
||||
var errorMessage = '';
|
||||
|
||||
if (errors) {
|
||||
$.each(errors, function(key, value) {
|
||||
errorMessage += value[0] + '<br>';
|
||||
});
|
||||
} else {
|
||||
errorMessage = 'Terjadi kesalahan saat menyimpan data';
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Gagal',
|
||||
html: errorMessage
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user