@extends('admin.layouts.main', ['scripts' => [path_asset('path.backoffice.js_path') . '/view/generic/backend-generic-list.js']])

@section('content')
<h1>{{ ucfirst($contentType->getLabel()) }}</h1>
<div id="generic_wrapper">
    @if($contentType->hasActions("grid"))
    <div class="grid-btns-wrapper">
        @foreach($contentType->getActions("grid") as $action)
        <button type="button" data-toggle="tooltip" data-placement="right" class="btn btn-default command-{{ $action->getType() }}" title="{{ $action->getLabel() }}">
            <span class="icon glyphicon {{ $action->getCssClass() }}"></span>
        </button>
        @endforeach
    </div>
    @endif
    <table id="grid" class="table table-condensed table-hover table-striped">
        <thead>
            <tr>
                <th data-column-id="id" data-type="numeric" data-identifier="true" data-visible="false">ID</th>
                @foreach($contentType->getFields()->getListableFields() as $field)
                {!! $field->toGridHeader() !!}
                @endforeach

                @if($contentType->getShowSlug())
                <th data-column-id="slug">Slug</th>
                @endif

                @if($contentType->getShowUri())
                <th data-column-id="uri">Uri</th>
                @endif

                @if($contentType->usesContentStructure())
                <th data-column-id="status">Status</th>
                @endif

                @if($contentType->hasActions("row"))
                <th data-column-id="commands" data-formatter="commands" data-sortable="false">{{ trans('backend.actions') }}</th>
                @endif
            </tr>
        </thead>
    </table>
</div>
<script>
    $(function() {
        var genericListView = new Eae.View.BackendGenericList({
            el: $('#generic_wrapper'),
            contentType: {!!$contentType->toJson() !!}
        });
    });
</script>

@stop