@extends('layouts.layout-2')

@section('content')

    <h4 class="font-weight-bold py-3 mb-1">
        {{ __('Inhalte') }}  {{ __('Allgemein') }}
    </h4>

    @if ($errors->any())
        <div class="row">
            <div class="col-sm-12">
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
    @endif

    <div class="card">
        <div class="card-datatable table-responsive py-2"  >
            <div class="mr-4 mb-2 text-right">
                <button type="button" class="btn btn-sm btn-primary" data-toggle="modal"
                        data-target="#modals-load-content"
                        data-id="new"
                        data-identifier="{{$identifier_content}}"
                        data-model="content"
                        data-back="{{route('cms_content_all')}}"
                        data-route="{{ route('cms_content_all_load_modal') }}"
                >Neuen Content anlegen</button>
            </div>

            <table class="datatables-default table table-striped table-bordered clients-table">
                <thead>
                <tr>
                    <th style="max-width: 60px;">&nbsp;</th>
                    <th>{{__('Name')}}</th>
                    <th>{{__('Slug')}}</th>
                    <th>{{__('Inhalt')}}</th>
                    <th>{{__('Type')}}</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                @foreach($contents as $value)
                    <tr>
                        <td class="not">
                            <button type="button" class="btn icon-btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
                                    data-id="{{ $value->id }}"
                                    data-identifier="{{$identifier_content}}"
                                    data-model="content"
                                    data-back="{{route('cms_content_all')}}"
                                    data-route="{{ route('cms_content_all_load_modal') }}">
                                <span class="fa fa-edit"></span>
                            </button>
                        </td>
                        <td>{{ $value->name }}</td>
                        <td>{{ $value->slug }}</td>
                        <td>@if($value->isFile()) {!! $value->getPreviewContent() !!} @else {{ $value->getPreviewContent() }} @endif</td>
                        <td>{{ $value->getFieldName() }}</td>
                        <td><a class="text-danger" href="{{ route('cms_content_all_delete', [$value->id]) }}"  onclick="return confirm('{{__('Wirklich löschen?')}}');"><i class="fa fa-trash-alt"></i></a></td>
                    </tr>
                @endforeach
                </tbody>
            </table>
            <div class="mt-4 mr-4 text-right">
                <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modals-load-content"
                        data-id="new"
                        data-identifier="{{$identifier_content}}"
                        data-model="content"
                        data-back="{{route('cms_content_all')}}"
                        data-route="{{ route('cms_content_all_load_modal') }}"
                >Neuen Content anlegen</button>
            </div>
        </div>
    </div>
        <script>
            $( document ).ready(function() {

                $('.datatables-default').dataTable({
                    "bLengthChange": false,
                    "iDisplayLength": 50,
                    "language": {
                        "url": "/js/German.json"
                    }
                });

            });

        </script>
@endsection