2020-08-04 11:21:23 +00:00
|
|
|
@extends("admin.layout.base")
|
|
|
|
@extends("admin.layout.header")
|
|
|
|
|
|
|
|
@section("title")
|
2020-10-27 08:32:23 +00:00
|
|
|
Vejledning - Vis
|
2020-08-04 11:21:23 +00:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section("path")
|
2020-10-07 06:25:00 +00:00
|
|
|
<a href="{{ route('guides.index') }}" class="text-white">Vis Vejledning</a> /
|
2020-08-04 11:21:23 +00:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section("content")
|
2020-10-21 07:12:53 +00:00
|
|
|
<style>
|
|
|
|
.letterSpaceTable{
|
|
|
|
letter-spacing: 1.2px;
|
|
|
|
}
|
|
|
|
</style>
|
2020-08-31 08:57:26 +00:00
|
|
|
@if(auth()->user()->can('guides.create'))
|
|
|
|
<div class="row align-items-center mb-2">
|
|
|
|
<a class="btn btn-inline btn-sde-blue mb-0" href="{{ route('guides.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret Bruger Vejledning</a>
|
2020-09-10 13:31:06 +00:00
|
|
|
<a class="btn btn-inline btn-sde-blue mb-0 ml-1" href="{{ route('guides-category.create') }}"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret vejlednings kategori</a>
|
2020-08-31 08:57:26 +00:00
|
|
|
</div>
|
|
|
|
@endif
|
2020-10-21 07:12:53 +00:00
|
|
|
<div id="guides" class="letterSpaceTable">
|
2020-09-10 13:31:06 +00:00
|
|
|
<label>Vejledninger</label>
|
2020-12-01 11:05:18 +00:00
|
|
|
</div>
|
|
|
|
<table class="tbl letterSpaceTable fixOverflow">
|
2020-08-04 11:21:23 +00:00
|
|
|
<tr>
|
|
|
|
<th>Navn</th>
|
2020-09-11 10:30:37 +00:00
|
|
|
<th>Kategori</th>
|
2021-04-09 23:43:05 +00:00
|
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/preview.svg') }}" alt="preview"></th>
|
2020-08-31 08:57:26 +00:00
|
|
|
@if(auth()->user()->can('guides.edit'))
|
2020-11-26 09:19:12 +00:00
|
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
|
2020-08-31 08:57:26 +00:00
|
|
|
@endif
|
|
|
|
@if(auth()->user()->can('guides.delete'))
|
2020-11-26 09:19:12 +00:00
|
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
|
2020-08-31 08:57:26 +00:00
|
|
|
@endif
|
2020-08-04 11:21:23 +00:00
|
|
|
</tr>
|
|
|
|
@foreach($guides as $guide)
|
2020-12-01 11:05:18 +00:00
|
|
|
<tr id="guide_row_{{ $guide->id }}" data-id="guide_category_row{{ \App\GuidesCategory::query()->where('id', '=', $guide->guide_category_id)->first()->id }}">
|
2020-08-04 11:21:23 +00:00
|
|
|
<td>{{$guide->name}}</td>
|
2020-09-11 10:30:37 +00:00
|
|
|
<td>{{ \App\GuidesCategory::query()->where('id', '=', $guide->guide_category_id)->first()->guidesCategoryName }}</td>
|
2021-04-09 23:43:05 +00:00
|
|
|
<td><a id="preview" onclick="modalNewsContent({{$guide->id}})" style="cursor: pointer" ><img class="w-100" src="{{ asset('/images/icons/preview-dark.svg') }}" alt="preview"></a></td>
|
2020-08-31 08:57:26 +00:00
|
|
|
@if(auth()->user()->can('guides.edit'))
|
|
|
|
<td><a href="{{ route("guides.edit", [ "guide" => $guide ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
|
|
|
@endif
|
|
|
|
@if(auth()->user()->can('guides.delete'))
|
2020-12-01 11:05:18 +00:00
|
|
|
<td>
|
|
|
|
@csrf
|
|
|
|
<a class="w-100 nostyle" onclick="delete_guide({{ $guide->id }})"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a>
|
2020-08-04 11:21:23 +00:00
|
|
|
|
2020-08-31 08:57:26 +00:00
|
|
|
</td>
|
|
|
|
@endif
|
2020-08-04 11:21:23 +00:00
|
|
|
</tr>
|
|
|
|
@endforeach
|
2020-10-07 06:25:00 +00:00
|
|
|
@if(count($guides) == 0)
|
|
|
|
<tr>
|
2020-10-30 13:18:28 +00:00
|
|
|
<td colspan="5">Ingen vejledninger</td>
|
2020-10-07 06:25:00 +00:00
|
|
|
</tr>
|
|
|
|
@endif
|
2020-08-04 11:21:23 +00:00
|
|
|
</table>
|
2020-10-21 07:12:53 +00:00
|
|
|
<div id="guidesCategory" class="mt-2 letterSpaceTable">
|
2020-09-10 13:31:06 +00:00
|
|
|
<label>Kategorier til de forskellige vejledninger</label>
|
|
|
|
<table class="tbl">
|
|
|
|
<tr>
|
|
|
|
<th>Vejlednings kategorier</th>
|
|
|
|
@if(auth()->user()->can('guides.edit'))<!--Jeg ved ikke om vi lave mere specifike permissions-->
|
2020-11-26 09:19:12 +00:00
|
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
|
2020-09-10 13:31:06 +00:00
|
|
|
@endif
|
|
|
|
@if(auth()->user()->can('guides.delete'))<!--Jeg ved ikke om vi lave mere specifike permissions-->
|
2020-11-26 09:19:12 +00:00
|
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
|
2020-09-10 13:31:06 +00:00
|
|
|
@endif
|
|
|
|
</tr>
|
|
|
|
@foreach(\App\GuidesCategory::query()->get() as $guideCategory)
|
2020-12-01 11:05:18 +00:00
|
|
|
<tr id="category_row_{{ $guideCategory->id }}">
|
2020-09-10 13:31:06 +00:00
|
|
|
<td>{{$guideCategory->guidesCategoryName}}</td>
|
2020-09-14 06:57:31 +00:00
|
|
|
@if(auth()->user()->can('guides.edit'))
|
|
|
|
<td><a href="{{ route("guides-category.edit", $guideCategory) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update2"></a></td>
|
|
|
|
@endif
|
|
|
|
@if(auth()->user()->can('guides.delete'))
|
2020-12-01 11:05:18 +00:00
|
|
|
<td>
|
|
|
|
@csrf
|
|
|
|
<a class="w-100 nostyle" onclick="delete_category({{ $guideCategory->id }})"><img class="w-100 cursor-pointer" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a>
|
2020-09-14 06:57:31 +00:00
|
|
|
</td>
|
|
|
|
@endif
|
2020-09-10 13:31:06 +00:00
|
|
|
</tr>
|
|
|
|
@endforeach
|
|
|
|
</table>
|
|
|
|
</div>
|
2020-10-30 13:18:28 +00:00
|
|
|
|
|
|
|
|
2021-04-09 23:43:05 +00:00
|
|
|
<div id="newsModal" class="modal zindex-100">
|
|
|
|
<div id="modal-content" class="modal-content text-black d-block w-50">
|
|
|
|
<span class="close" onclick="closeModal()">×</span>
|
|
|
|
<center>
|
|
|
|
<h1 id="name"></h1>
|
|
|
|
<hr>
|
2021-04-19 12:42:03 +00:00
|
|
|
<img id="eventimg">
|
2021-04-09 23:43:05 +00:00
|
|
|
<strong><label for="guide_articles">Vejledning</label></strong>
|
|
|
|
<p id="guide_articles"></p>
|
|
|
|
</center>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@endsection
|
|
|
|
@section('scripts')
|
2020-10-30 13:18:28 +00:00
|
|
|
<script>
|
2021-04-09 23:43:05 +00:00
|
|
|
var modalNews = document.getElementById("newsModal");
|
|
|
|
|
|
|
|
function modalNewsContent(id) {
|
|
|
|
$.ajax({
|
|
|
|
type: 'get',
|
|
|
|
url: '{{route('guides.preview')}}',
|
|
|
|
data: {'preview':id},
|
|
|
|
success:function (data) {
|
2021-04-19 06:12:50 +00:00
|
|
|
modalNews.style.display = "flex";
|
2021-04-09 23:43:05 +00:00
|
|
|
var l = JSON.parse(data);
|
|
|
|
console.log(l);
|
|
|
|
$("#name").html(l.name);
|
|
|
|
$("#guide_articles").html(l.guide_articles);
|
2021-04-19 12:42:03 +00:00
|
|
|
if (l.filename)
|
|
|
|
$("#eventimg").attr('src', l.filename);
|
|
|
|
|
2021-04-09 23:43:05 +00:00
|
|
|
},
|
|
|
|
error:function (data) {
|
|
|
|
console.log(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function closeModal() {
|
|
|
|
modalNews.style.display = "none";
|
2021-04-19 12:42:03 +00:00
|
|
|
$("#name").html('');
|
|
|
|
$("#guide_articles").html('');
|
|
|
|
$("#eventimg").attr('src', '');
|
2021-04-09 23:43:05 +00:00
|
|
|
}
|
2020-10-30 13:18:28 +00:00
|
|
|
|
2021-04-09 23:43:05 +00:00
|
|
|
window.onmousedown = function(event) {
|
|
|
|
if (event.target == modalNews) {
|
|
|
|
modalNews.style.display = "none";
|
2021-04-19 12:42:03 +00:00
|
|
|
$("#name").html('');
|
|
|
|
$("#guide_articles").html('');
|
|
|
|
$("#eventimg").attr('src', '');
|
2021-04-09 23:43:05 +00:00
|
|
|
}
|
2020-10-30 13:18:28 +00:00
|
|
|
}
|
|
|
|
</script>
|
2020-12-01 11:05:18 +00:00
|
|
|
<script>
|
|
|
|
function delete_guide(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 Vejledningen',
|
|
|
|
cancelButtonText: 'Annuller'
|
|
|
|
}).then((result) => {
|
|
|
|
if (result.isConfirmed) {
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "guides/"+id,
|
|
|
|
data:{'_token':token, _method: 'DELETE'},
|
|
|
|
success: function () {
|
|
|
|
$('#guide_row_'+id).remove();
|
|
|
|
|
|
|
|
Swal.fire(
|
|
|
|
'Vejledningen er slettet!',
|
|
|
|
'',
|
|
|
|
'success'
|
|
|
|
)
|
|
|
|
},
|
|
|
|
error:function (data) {
|
|
|
|
console.log(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function delete_category(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 Kategorien',
|
|
|
|
cancelButtonText: 'Annuller'
|
|
|
|
}).then((result) => {
|
|
|
|
if (result.isConfirmed) {
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
url: "guides-category/"+id,
|
|
|
|
data:{'_token':token, _method: 'DELETE'},
|
|
|
|
success: function () {
|
|
|
|
$('#category_row_'+id).remove();
|
|
|
|
|
|
|
|
location.reload();
|
|
|
|
},
|
|
|
|
error:function (data) {
|
|
|
|
console.log(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
@endsection
|