214 lines
8.7 KiB
PHP
214 lines
8.7 KiB
PHP
@extends("admin.layout.base")
|
|
@extends("admin.layout.header")
|
|
|
|
@section("title")
|
|
Vejledning - Vis
|
|
@endsection
|
|
|
|
@section("path")
|
|
<a href="{{ route('guides.index') }}" class="text-white">Vis Vejledning</a> /
|
|
@endsection
|
|
|
|
@section("content")
|
|
<style>
|
|
.letterSpaceTable{
|
|
letter-spacing: 1.2px;
|
|
}
|
|
</style>
|
|
@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>
|
|
<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>
|
|
</div>
|
|
@endif
|
|
<div id="guides" class="letterSpaceTable">
|
|
<label>Vejledninger</label>
|
|
</div>
|
|
<table class="tbl letterSpaceTable fixOverflow">
|
|
<tr>
|
|
<th>Navn</th>
|
|
<th>Kategori</th>
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/preview.svg') }}" alt="preview"></th>
|
|
@if(auth()->user()->can('guides.edit'))
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
|
|
@endif
|
|
@if(auth()->user()->can('guides.delete'))
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
|
|
@endif
|
|
</tr>
|
|
@foreach($guides as $guide)
|
|
<tr id="guide_row_{{ $guide->id }}" data-id="guide_category_row{{ \App\GuidesCategory::query()->where('id', '=', $guide->guide_category_id)->first()->id }}">
|
|
<td>{{$guide->name}}</td>
|
|
<td>{{ \App\GuidesCategory::query()->where('id', '=', $guide->guide_category_id)->first()->guidesCategoryName }}</td>
|
|
<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>
|
|
@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'))
|
|
<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>
|
|
|
|
</td>
|
|
@endif
|
|
</tr>
|
|
@endforeach
|
|
@if(count($guides) == 0)
|
|
<tr>
|
|
<td colspan="5">Ingen vejledninger</td>
|
|
</tr>
|
|
@endif
|
|
</table>
|
|
<div id="guidesCategory" class="mt-2 letterSpaceTable">
|
|
<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-->
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/pencil.svg') }}" alt="Update"></th>
|
|
@endif
|
|
@if(auth()->user()->can('guides.delete'))<!--Jeg ved ikke om vi lave mere specifike permissions-->
|
|
<th class="w-1em"><img class="w-100" src="{{ asset('/images/icons/trashcan.svg') }}" alt="Delete"></th>
|
|
@endif
|
|
</tr>
|
|
@foreach(\App\GuidesCategory::query()->get() as $guideCategory)
|
|
<tr id="category_row_{{ $guideCategory->id }}">
|
|
<td>{{$guideCategory->guidesCategoryName}}</td>
|
|
@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'))
|
|
<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>
|
|
</td>
|
|
@endif
|
|
</tr>
|
|
@endforeach
|
|
</table>
|
|
</div>
|
|
|
|
|
|
<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>
|
|
<img id="eventimg">
|
|
<strong><label for="guide_articles">Vejledning</label></strong>
|
|
<p id="guide_articles"></p>
|
|
</center>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
@section('scripts')
|
|
<script>
|
|
var modalNews = document.getElementById("newsModal");
|
|
|
|
function modalNewsContent(id) {
|
|
$.ajax({
|
|
type: 'get',
|
|
url: '{{route('guides.preview')}}',
|
|
data: {'preview':id},
|
|
success:function (data) {
|
|
modalNews.style.display = "flex";
|
|
var l = JSON.parse(data);
|
|
console.log(l);
|
|
$("#name").html(l.name);
|
|
$("#guide_articles").html(l.guide_articles);
|
|
if (l.filename)
|
|
$("#eventimg").attr('src', l.filename);
|
|
|
|
},
|
|
error:function (data) {
|
|
console.log(data);
|
|
}
|
|
});
|
|
}
|
|
|
|
function closeModal() {
|
|
modalNews.style.display = "none";
|
|
$("#name").html('');
|
|
$("#guide_articles").html('');
|
|
$("#eventimg").attr('src', '');
|
|
}
|
|
|
|
window.onmousedown = function(event) {
|
|
if (event.target == modalNews) {
|
|
modalNews.style.display = "none";
|
|
$("#name").html('');
|
|
$("#guide_articles").html('');
|
|
$("#eventimg").attr('src', '');
|
|
}
|
|
}
|
|
</script>
|
|
<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
|