partial update close modal on all page and disable create transaction with no stock
This commit is contained in:
@@ -48,18 +48,14 @@
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $role->name }}</td>
|
||||
<td>
|
||||
@can('update', $menus['roleprivileges.index'])
|
||||
<button class="btn btn-sm btn-warning" onclick="editRole({{$role->id}})"><i class="fa fa-edit"></i> Edit</button>
|
||||
@endcan
|
||||
@can('delete', $menus['roleprivileges.index'])
|
||||
<br>
|
||||
<br>
|
||||
<form action="{{ route('roleprivileges.delete', $role->id) }}" method="post" onsubmit="return confirm('Anda akan menghapus role {{ $role->name }}?');">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-sm btn-danger"><i class="fa fa-trash"></i> Hapus</button>
|
||||
</form>
|
||||
@endcan
|
||||
<div class="d-flex">
|
||||
@can('update', $menus['roleprivileges.index'])
|
||||
<button class="btn btn-sm btn-bold btn-warning mr-2" onclick="editRole({{$role->id}})"> Edit</button>
|
||||
@endcan
|
||||
@can('delete', $menus['roleprivileges.index'])
|
||||
<button class="btn btn-sm btn-bold btn-danger" onclick="deleteRole({{$role->id}}, '{{$role->name}}')">Hapus</button>
|
||||
@endcan
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@@ -191,6 +187,41 @@
|
||||
|
||||
@section('javascripts')
|
||||
<script>
|
||||
function deleteRole(id, name) {
|
||||
Swal.fire({
|
||||
title: 'Hapus Role?',
|
||||
text: `Anda akan menghapus role ${name}?`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#6c757d',
|
||||
confirmButtonText: 'Ya, Hapus!',
|
||||
cancelButtonText: 'Batal'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
// Create form and submit
|
||||
let form = document.createElement('form');
|
||||
form.method = 'POST';
|
||||
form.action = '{{ route("roleprivileges.delete", ":id") }}'.replace(':id', id);
|
||||
|
||||
let csrfToken = document.createElement('input');
|
||||
csrfToken.type = 'hidden';
|
||||
csrfToken.name = '_token';
|
||||
csrfToken.value = '{{ csrf_token() }}';
|
||||
|
||||
let methodField = document.createElement('input');
|
||||
methodField.type = 'hidden';
|
||||
methodField.name = '_method';
|
||||
methodField.value = 'DELETE';
|
||||
|
||||
form.appendChild(csrfToken);
|
||||
form.appendChild(methodField);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editRole(id) {
|
||||
let url = '{{ route("roleprivileges.edit", ":id") }}'
|
||||
url = url.replace(':id', id);
|
||||
@@ -265,5 +296,18 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
$(document).ready(function () {
|
||||
// Add event handlers for modal close buttons
|
||||
$('.close, [data-dismiss="modal"]').on("click", function () {
|
||||
$("#roleModal").modal("hide");
|
||||
$("#roleEditModal").modal("hide");
|
||||
});
|
||||
|
||||
// Also handle the "Close" button
|
||||
$('.btn-secondary[data-dismiss="modal"]').on("click", function () {
|
||||
$("#roleModal").modal("hide");
|
||||
$("#roleEditModal").modal("hide");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user