@if ($category['id'] ?? false)
    <div class="d-flex justify-content-end mb-3">
        <a href="{{ route('Admin.Shop.Articles.index', ['category_id' => $category['id']]) }}" class="btn btn-outline-primary">
            Voir les articles de ce rayon
            <i class="fa fa-external-link"></i>
        </a>
    </div>
@endif

<div class="row">
	<div class="col-9">
		<div class="row mb-3">
			<div class="col-5">
				{{ Form::label('name', 'Nom') }}
				@include('components.form.input', ['name' => 'name', 'value' => $category['name'] ?? null, 'required' => true])
			</div>
			<div class="col-5">
				{{ Form::label('parent', 'Rayon parent') }}
				@include('components.form.select', [
					'name' => 'parent_id',
					'list' => $categories ?? [],
					'value' => $category['parent_id'] ?? null,
					'required' => true,
					'with_empty' => '',
					'class' => 'select2',
				])
			</div>
			<div class="col-1 text-center">
				{{ Form::label('homepage', 'Accueil') }}<br/>
				@include('components.form.toggle', ['name' => 'homepage', 'value' => $category['homepage'] ?? null])
			</div>
			<div class="col-1 text-right">
				{{ Form::label('visible', 'Visible') }}<br/>
				@include('components.form.toggle', ['name' => 'visible', 'value' => $category['visible'] ?? null])
			</div>
		</div>
		<div class="row mb-3">
			<div class="col-12">
				{{ Form::label('tags', 'Tags') }}
				@include('components.form.selects.select-tree', [
					'name' => 'tags[]',
					'list' => $tags_list,
					'values' => $category['tags'] ?? null,
					'class' => 'select2',
					'multiple' => true,
				])
			</div>
		</div>		
		<div class="row mb-3">
			<div class="col-12">
				{{ Form::label('description', 'Description') }}
				@include('components.form.textarea', ['name' => 'description', 'value' => $category['description'] ?? null, 'class' => 'editor', 'required' => true])
			</div>
		</div>
	</div>
	<div class="col-3">
	</div>
</div>

@include('components.save')

@include('load.form.select2')
@include('load.form.editor')
@include('load.form.save')

@push('js')
	<script>
		$(function() {
			initSaveForm('#category-form');
			initSelect2();
			initEditor();
		});
	</script>
@endpush