v1.5.3 - Added Swal on all index pages
This commit is contained in:
@@ -18,12 +18,12 @@
|
||||
letter-spacing: 1.2px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row align-items-center">
|
||||
@if(auth()->user()->can('event.show'))
|
||||
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('events.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Aktivitet</a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<table class="tbl mt-2 letterSpaceTable fixOverflow" id="table_id">
|
||||
<thead>
|
||||
<th>Aktivitet Navn</th>
|
||||
@@ -40,7 +40,7 @@
|
||||
<tbody>
|
||||
@foreach($events as $event)
|
||||
@if (date('Y-m-d H:i', strtotime('-1 day')) < date('Y-m-d H:i', strtotime($event->date)))
|
||||
<tr>
|
||||
<tr id="row_{{ $event->id }}">
|
||||
<td>{{ $event->name }}</td>
|
||||
<td>{{ $event->accountable }}</td>
|
||||
<td>{{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($event->date))->format('d/m/Y \k\l\. H:i') }}</td>
|
||||
@@ -49,12 +49,9 @@
|
||||
<td><a href="{{ route("events.edit", [ "event" => $event ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
||||
@endif
|
||||
@if(auth()->user()->can('event.delete'))
|
||||
<td><form method="post" action="{{ route("events.destroy", [ "event" => $event ]) }}" class="w-100 nostyle">
|
||||
@csrf
|
||||
@method("delete")
|
||||
|
||||
<button class="w-100 nostyle" onclick="return confirm('Are you sure you want to delete?');" 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_event({{ $event->id }})"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a>
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
@@ -72,5 +69,40 @@
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
function delete_event(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 Aktiviteten',
|
||||
cancelButtonText: 'Annuller'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "events/"+id,
|
||||
data:{'_token':token, _method: 'DELETE'},
|
||||
success: function () {
|
||||
$('#table_id').DataTable().row($('#row_'+id)[0]).remove().draw();
|
||||
|
||||
Swal.fire(
|
||||
'Aktiviteten er slettet!',
|
||||
'',
|
||||
'success'
|
||||
)
|
||||
},
|
||||
error:function (data) {
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user