v1.5.3 - Added Swal on all index pages
This commit is contained in:
@@ -27,17 +27,14 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($feedback as $fb)
|
||||
<tr>
|
||||
<tr id="row_{{ $fb->id }}">
|
||||
<td>{{ date('d-m-Y', strtotime($fb->created_at)) }}</td>
|
||||
<td>{{ $fb->message }}</td>
|
||||
<td>{{ $fb->suggestion_form }}</td>
|
||||
@if(auth()->user()->can('feedback.delete'))
|
||||
<td><form method="post" action="{{ route("feedbacks.destroy", [ "feedback" => $fb ]) }}" class="w-100 nostyle">
|
||||
@csrf
|
||||
@method("delete")
|
||||
|
||||
<button onclick="return confirm('Are you sure you want to delete?');" class="w-100 nostyle" type="submit"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
|
||||
</form>
|
||||
<td>
|
||||
@csrf
|
||||
<a class="w-100 nostyle" onclick="delete_feedback({{ $fb->id }})"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a>
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
@@ -54,5 +51,40 @@
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
function delete_feedback(id) {
|
||||
var token = $("input[name='_token']").val();
|
||||
|
||||
Swal.fire({
|
||||
title: 'Er du sikker?',
|
||||
text: "Dette kan ikke blive ændret tilbage!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Slet Feedback',
|
||||
cancelButtonText: 'Annuller'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "feedbacks/"+id,
|
||||
data:{'_token':token, _method: 'DELETE'},
|
||||
success: function () {
|
||||
$('#table_id').DataTable().row($('#row_'+id)[0]).remove().draw();
|
||||
|
||||
Swal.fire(
|
||||
'Feedbacken er slettet!',
|
||||
'',
|
||||
'success'
|
||||
)
|
||||
},
|
||||
error:function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user