@extends(Theme::viewName('layout'))
@section('title', trans('admin.list_labels_title'))

@section('breadcrumb')
    <li class="breadcrumb-item"><a href="{{ route('home') }}"><i class="fa fa-fw fa-home"></i></a></li>
    <li class="breadcrumb-item"><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
    <li class="breadcrumb-item active">@lang('navigation.breadcrumb.labels')</li>
@endsection

@section('content')
    <div class="container">
        <div class="row">
            <div class="col">
                <h1>@yield('title')</h1>
                <div class="alert alert-info mb-4">
                    <i class="fa fa-fw fa-info"></i> @lang('admin.list_labels_intro')
                </div>

                @if (count($labels) == 0)
                    <div class="text-center mb-4">
                        <h4 class="text-danger"><b>@lang('admin.no_labels_title')</b></h4>
                        <p>@lang('admin.no_labels_text')</p>
                    </div>
                @else
                    <p>@lang('admin.labels_intro')</p>
                    <ul class="nav nav-pills">
                        @foreach ($labels as $label)
                            <li class="nav-item">
                                <a class="nav-link" href="{{ route('labels.delete', [$label->id]) }}">
                                    {{ $label->name }} ({{ number_format($label->photos_count, 0) }})&nbsp;&nbsp;
                                    <i class="fa fa-trash text-danger"></i>
                                </a>
                            </li>
                        @endforeach
                    </ul>
                @endif

                <hr/>
                <h3>@lang('admin.create_label_title')</h3>
                <p class="mb-5">@lang('admin.create_label_intro')</p>

                <form action="{{ route('labels.store') }}" method="POST">
                    {{ csrf_field() }}
                    <div class="form-group row">
                        <label class="form-control-label col-md-1" for="label-name">@lang('forms.name_label')</label>
                        <div class="col-md-9 mb-3">
                            <input type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" id="label-name" name="name" value="{{ old('name') }}">

                            @if ($errors->has('name'))
                                <div class="invalid-feedback">
                                    <strong>{{ $errors->first('name') }}</strong>
                                </div>
                            @endif
                        </div>

                        <div class="col-md-2 text-right">
                            <button type="submit" class="btn btn-success" style="width: 100%;"><i class="fa fa-check"></i> @lang('forms.create_action')</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection

@push('scripts')
    <script type="text/javascript">
        $(document).ready(function()
        {
            $('#label-name').focus();
        });
    </script>
@endpush