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

@section('content')
    <h1>{{ ucfirst($contentType->getLabel()) }}</h1>
    @if($contentType->getShareable() == 'global')
    <h3>*these contents are shared across sites*</h3>
    @endif
    <div id="generic_wrapper">
        @if($contentType->getSubTypes())
        <div class="sub-type-filter">
            <div class="btn-group" role="group">
                <button type="button" class="btn btn-default active command-filter-subtype" data-subtype="">
                    All
                </button>
                @foreach($contentType->getSubTypes() as $subType => $data)
                    <button type="button" class="btn btn-default command-filter-subtype" data-subtype="{{ $subType }}">
                        {{ $data['label'] }}
                    </button>
                @endforeach
            </div>
        </div>
        @endif
        @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="{{ $contentType->getShowId() ? 'true' : '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

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

@stop
