ldc-wenn-dann-mit-respekt/resources/views/bo/pages/news/form-inputs.blade.php
2023-06-13 13:13:56 +02:00

259 lines
No EOL
11 KiB
PHP

<div class="row">
{{-- SEO_TITLE --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ __('SEO Title') }}</legend>
<div class="row">
<div class="col-12 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => 'newsSeoTitle',
'label' => __('SEO title of the :model', ['model' => Str::singular(__('models.classes.news'))]),
'hasWordCounter' => true,
'name' => 'seo_title',
'required' => true,
'model' => $newsModel ?? null,
'helper' => __('validation.between.string', [
'attribute' => __('SEO title of the :model', ['model' => Str::singular(__('models.classes.news'))]),
'min' => 3,
'max' => 255
]),
'placeholder' => __('A beautiful title'),
])
</div>
</div>
</fieldset>
</div>
{{-- SEO_DESCRIPTION --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ __('SEO Description') }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.varchar-multiline', [
'id' => 'newsSeoDescription',
'label' => __('SEO description of the :model', ['model' => Str::singular(__('models.classes.news'))]),
'name' => 'seo_description',
'model' => $newsModel ?? null,
'required' => true,
'helper' => __('validation.between.string', [
'attribute' => __('SEO description of the :model', ['model' => Str::singular(__('models.classes.products'))]),
'min' => 50,
'max' => 160
]),
'placeholder' => __('A description of the content for search engines.'),
])
</div>
</div>
</fieldset>
</div>
</div>
<div class="row">
{{-- TITLE --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ __('Title') }}</legend>
<div class="row">
<div class="col-12 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => 'newsTitle',
'label' => __('Title of the :model', ['model' => Str::singular(__('models.classes.news'))]),
'hasWordCounter' => true,
'name' => 'title',
'required' => true,
'model' => $newsModel ?? null,
'helper' => __('validation.between.string', [
'attribute' => __('Title of the :model', ['model' => Str::singular(__('models.classes.news'))]),
'min' => 3,
'max' => 255
]),
'placeholder' => __('A beautiful title'),
])
</div>
</div>
</fieldset>
</div>
{{-- SUBTITLE --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ __('Subtitle') }}</legend>
<div class="row">
<div class="col-12 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => 'newsSubtitle',
'label' => __('Subtitle of the :model', ['model' => Str::singular(__('models.classes.news'))]),
'hasWordCounter' => true,
'name' => 'subtitle',
'required' => true,
'model' => $newsModel ?? null,
'helper' => __('validation.between.string', [
'attribute' => __('Subtitle of the :model', ['model' => Str::singular(__('models.classes.news'))]),
'min' => 3,
'max' => 255
]),
'placeholder' => __('A beautiful subtitle'),
])
</div>
</div>
</fieldset>
</div>
{{-- CONTENT --}}
<div class="col-12 mb-3">
<fieldset class="border bg-white p-3">
<legend>{{ __('Content') }}</legend>
<div class="row mb-3">
<div class="col-12">
@include('bo.partials.inputs.text-html', [
'id' => 'newContent',
'label' => __('Description of the :model', ['model' => Str::singular(__('models.classes.news'))]),
'name' => 'content',
'model' => $newsModel ?? null,
'required' => true,
'helper' => __('Proofread your content before publishing it (minimum 15 characters).'),
])
</div>
</div>
</fieldset>
</div>
{{-- MINICRUD --}}
<div class="col-12 mb-3">
<button class="btn btn-primary col-form-label rounded-0 dropdown-toggle w-100" type="button" data-bs-toggle="collapse" data-bs-target="#minicrud" aria-expanded="false" aria-controls="minicrud">
<b>{{ __('ALL BLOCS') }}</b>
</button>
<div class="collapse" id="minicrud">
<div class="card card-body bg-light rounded-0">
<div class="row">
@include('bo.modules.minicrud-form-inputs', [
'data' => $newsModel->data ?? \App\Models\News::getEmptyData()
])
</div>
</div>
</div>
</div>
{{-- PUBLICATION --}}
<div class="col-12 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ __('Publication') }}</legend>
<div class="row mb-3">
<div class="col">
<div class="form-group">
@include('bo.partials.inputs.publish-dates', [
'label' => __('Date de publication (Europe/Paris)'),
'id' => 'newsPublishedAt',
'name' => 'publish_at',
'model' => $newsModel ?? null,
])
</div>
</div>
<div class="col">
<div class="form-group">
@include('bo.partials.inputs.publish-dates', [
'label' => __('Date de fin de publication (Europe/Paris)'),
'id' => 'newsUnPublishedAt',
'name' => 'unpublish_at',
'model' => $newsModel ?? null,
])
</div>
</div>
</div>
</fieldset>
</div>
{{-- LOCALES --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ __('Languages in which to display the news') }}</legend>
<div class="row">
<div class="col-12">
@php
$itemsList = collect(config('app.locales'))->map(fn($locale) => (object)[
'label' => $locale, 'value' => $locale,
]);
$values = collect(old('locales', $newsModel->locales ?? []))->values();
$selectedItemList = collect($itemsList)->filter(fn($locale) =>
$values->filter(fn($value) => $value === $locale->value)->count())->values();
@endphp
@include('bo.partials.inputs.select-multiple-enum', [
'id' => 'newsLocales',
'label' => __('Locales in which to display the news'),
'name' => 'locales',
'itemsSelected' => $selectedItemList,
'itemsList' => $itemsList,
'itemLimit' => [0, count($itemsList)],
'placeholder' => __('Search a specific Locales'),
'helper' => __('Select Locales(s) among this list in which the news should display (minimum 1, maximum :max)', [
'max' => count($itemsList)
]),
'required' => true,
])
</div>
</div>
</fieldset>
</div>
{{-- STATUS --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="border h-100 bg-white p-3">
<legend>{{ __('crud.minicrud.visibility_label') }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.tinyint-boolean', [
'id' => 'newsStatus',
'name' => 'status',
'model' => $newsModel ?? null,
'label' => __('crud.minicrud.visibility_label'),
'helper' => __('crud.minicrud.visibility_helper'),
])
</div>
</div>
</fieldset>
</div>
</div>
@push('scripts')
<script nonce="{{ $nonce }}">
document.addEventListener('DOMContentLoaded', function() {
const hasLoadedComponentsMarker = 'data[bloc_3_image][value]';
const displayBloc = function(index) {
const switchInput = document.querySelector(`input[name="data[bloc_${index}_display_picture][value]"]`);
const inputList = [
`data[bloc_${index}_image][value]`,
];
const inputs = [];
inputList.forEach((name) => {
const input = document.querySelector(`input[name="${name}"]`) ??
document.querySelector(`select[name="${name}"]`);
inputs.push(input);
});
inputs.forEach((input) => {
// * hide.
if (!switchInput.checked) {
input.closest('.minicrud-input ').classList.add('d-none');
}
});
switchInput.addEventListener('change', function() {
inputs.forEach((input) => {
// * Toggle hide.
input.closest('.minicrud-input ').classList.toggle('d-none');
});
});
};
const waitForLoaded = () => {
setTimeout(() => {
if (!document.querySelector(`input[name="${hasLoadedComponentsMarker}"]`)) {
waitForLoaded();
return;
}
displayBloc(1);
displayBloc(2);
displayBloc(3);
}, 300);
};
waitForLoaded();
});
</script>
@endpush