v1.5.3 - Added Swal on all index pages

This commit is contained in:
Anders
2020-12-01 12:05:18 +01:00
parent f42d401ac7
commit dc9c1bf113
20 changed files with 1813 additions and 1429 deletions
@@ -12,17 +12,14 @@
<h2 class="text-center sde-blue mb-0">{{__('msg.dinereservationer')}}</h2>
@foreach($reservations as $reservation)
@if(date('Y-m-d H:i:s', strtotime('-1 hour')) < $reservation->time)
<div class="reservation" style="margin: 0 32px 1.75rem 32px;">
<div id="row_{{ $reservation->id }}" class="reservation" style="margin: 0 32px 1.75rem 32px;">
<h3>{{ \App\WashingMachine::query()->find($reservation->machine_id)->name }}</h3>
<div class="row align-items-center">
<span style="font-size: 4vw; white-space: pre-line;"><b>{{__('msg.tid')}}:</b> {{ \Illuminate\Support\Facades\Date::createFromTimeStamp(strtotime($reservation->time))->format('d/m/Y \k\l\. H:i') }}
- {{ \App\Location::query()->where('id', '=', \App\WashingMachine::query()->find($reservation->machine_id)->location_id)->first()->name }}</span>
<form class="ml-auto" method="post" action="{{ route("washing-reservations.destroy", [ "washing_reservation" => $reservation ]) }}">
@csrf
@method("delete")
<input type="hidden" name="id" value="{{ $reservation->id }}">
<button class="btn btn-sde-blue mb-0" type="submit" onclick="return confirm('Are you sure you want to remove this reservation?');">{{__('msg.fjern')}}</button>
</form>
@csrf
<a class="btn btn-sde-blue ml-auto mb-0" onclick="delete_reservation({{ $reservation->id }})">{{__('msg.fjern')}}</a>
</div>
</div>
<?php
@@ -39,4 +36,36 @@
@endsection
@section("scripts")
<script src="{{ asset("/js/jquery-3.2.1.min.js") }}"></script>
<script>
function delete_reservation(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 Reservationen',
cancelButtonText: 'Annuller'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
type: "POST",
url: "/washing-reservations/"+id,
data:{'_token':token, _method: 'DELETE'},
success: function () {
$('#row_'+id).remove()
},
error:function (data) {
console.log(data);
}
});
}
})
}
</script>
@endsection