v1.5.3 - Added Swal on all index pages
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($news as $new)
|
||||
<tr>
|
||||
<tr id="row_{{ $new->id }}">
|
||||
<td>{{$new->subname}}</td>
|
||||
@if($new->news_expiration_date !== null)
|
||||
<td>{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($new->news_expiration_date))->format('d/m/Y \k\l\. H:i') }}</td>
|
||||
@@ -44,12 +44,9 @@
|
||||
<td><a href="{{ route("news.edit", [ "news" => $new ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
||||
@endif
|
||||
@if(auth()->user()->can('news.delete'))
|
||||
<td><form method="post" action="{{ route("news.destroy", [ "news" => $new ]) }}" 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_news({{ $new->id }})"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a>
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
@@ -66,5 +63,40 @@
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
function delete_news(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 Nyheden',
|
||||
cancelButtonText: 'Annuller'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "news/"+id,
|
||||
data:{'_token':token, _method: 'DELETE'},
|
||||
success: function () {
|
||||
$('#table_id').DataTable().row($('#row_'+id)[0]).remove().draw();
|
||||
|
||||
Swal.fire(
|
||||
'Nyheden er slettet!',
|
||||
'',
|
||||
'success'
|
||||
)
|
||||
},
|
||||
error:function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user