ldc-volena/resources/views/bo/pages/testimonials/form.blade.php
2025-03-14 10:50:26 +01:00

215 lines
11 KiB
PHP

<div class="row">
{{-- TYPE --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ Str::ucfirst(__('validation.custom.type')) }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.tinyint-enum', [
'id' => 'testimonialType',
'label' => __('Associer un type'),
'name' => 'type',
'model' => $testimonialModel ?? null,
'required' => true,
'associatedModels' => \App\Enums\Testimonials\TypeEnum::toArray(),
'helper' => __('Sélectionnez un type dans la liste déroulante.'),
])
</div>
</div>
</fieldset>
</div>
{{-- NAME --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ Str::ucfirst(__('validation.attributes.name')) }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.varchar', [
'id' => 'testimonialName',
'label' => __(':field :inter:model', [
'field' => Str::ucfirst(__('validation.attributes.name')),
'inter' => __('validation.custom.of_the.male'),
'model' => trans_choice('models.classes.testimonial', 1),
]),
'hasWordCounter' => true,
'name' => 'name',
'required' => true,
'model' => $testimonialModel ?? null,
'helper' => __('validation.between.string', [
'attribute' => __(':field :inter:model', [
'field' => __('validation.attributes.name'),
'inter' => __('validation.custom.of_the.male'),
'model' => trans_choice('models.classes.testimonial', 1),
]),
'min' => 3,
'max' => 255,
]),
'placeholder' => __('Le nom de la personne'),
])
</div>
</div>
</fieldset>
</div>
{{-- JOB --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ Str::ucfirst(__('validation.custom.job')) }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.varchar', [
'id' => 'testimonialJob',
'label' => __(':field :inter:model', [
'field' => Str::ucfirst(__('validation.custom.job')),
'inter' => __('validation.custom.of_the.male'),
'model' => trans_choice('models.classes.testimonial', 1),
]),
'hasWordCounter' => true,
'name' => 'job',
'required' => false,
'model' => $testimonialModel ?? null,
'helper' => __('validation.between.string', [
'attribute' => __(':field :inter1:person :inter2:model', [
'field' => __('validation.custom.job'),
'inter1' => __('validation.custom.of_the.female'),
'person' => __('validation.custom.person'),
'inter2' => __('validation.custom.of_the.male'),
'model' => trans_choice('models.classes.testimonial', 1),
]),
'min' => 3,
'max' => 255,
]),
'placeholder' => __('Le métier de la personne témoignant'),
])
</div>
</div>
</fieldset>
</div>
{{-- CONTENT --}}
<div class="col-12 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ Str::ucfirst(__('validation.attributes.content')) }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.text-html', [
'id' => 'testimonialContent',
'label' => __(':field :inter:model', [
'field' => Str::ucfirst(__('validation.attributes.content')),
'inter' => __('validation.custom.of_the.male'),
'model' => trans_choice('models.classes.testimonial', 1),
]),
'name' => 'content',
'model' => $testimonialModel ?? null,
'editorConfig' => \App\Enums\CkEditorConfigName::basic->name(),
'required' => true,
'helper' => __('crud.minicrud.text_warning'),
])
</div>
</div>
</fieldset>
</div>
{{-- PICTURE --}}
<div class="col-12 pb-3">
<fieldset class="h-100 border p-3">
<legend>{{ Str::ucfirst(__('validation.attributes.image')) }}</legend>
<div class="row mb-3">
{{-- PICTURE_ALT --}}
<div class="col-12 col-md-6 m-md-0 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => 'testimonialPictureAlt',
'label' => __(':field1 :inter1:field2 :inter2:model', [
'field1' => Str::ucfirst(__('validation.custom.alt_attribute')),
'inter1' => __('validation.custom.of_the.male'),
'field2' => __('validation.attributes.image'),
'inter2' => __('validation.custom.of_the.male'),
'model' => trans_choice('models.classes.testimonial', 1),
]),
'hasWordCounter' => true,
'name' => 'picture_alt',
'required' => true,
'model' => $testimonialModel ?? null,
'helper' => __('crud.minicrud.picture_alt_helper'),
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
'field1' => Str::ucfirst(__('validation.custom.alt_attribute')),
'inter1' => __('validation.custom.of_the.male'),
'field2' => __('validation.attributes.image'),
'inter2' => __('validation.custom.of_the.male'),
'model' => trans_choice('models.classes.testimonial', 1),
]),
])
</div>
{{-- PICTURE_TITLE --}}
<div class="col-12 col-md-6 mb-3">
@include('bo.partials.inputs.varchar', [
'id' => 'testimonialPictureTitle',
'label' => __(':field1 :inter1:field2 :inter2:model', [
'field1' => Str::ucfirst(__('validation.custom.title_attribute')),
'inter1' => __('validation.custom.of_the.male'),
'field2' => __('validation.attributes.image'),
'inter2' => __('validation.custom.of_the.male'),
'model' => trans_choice('models.classes.testimonial', 1),
]),
'hasWordCounter' => true,
'name' => 'picture_title',
'required' => true,
'model' => $testimonialModel ?? null,
'helper' => __('crud.minicrud.picture_title_helper'),
'placeholder' => __(':field1 :inter1:field2 :inter2:model', [
'field1' => Str::ucfirst(__('validation.custom.title_attribute')),
'inter1' => __('validation.custom.of_the.male'),
'field2' => __('validation.attributes.image'),
'inter2' => __('validation.custom.of_the.male'),
'model' => trans_choice('models.classes.testimonial', 1),
]),
])
</div>
{{-- PICTURE --}}
<div class="col-12">
@include('bo.partials.inputs.varchar-picture', [
'id' => 'testimonialPicture',
'name' => 'picture',
'width' => 150,
'height' => 150,
'model' => $testimonialModel ?? null,
'helper' => __('crud.minicrud.dimensions_must_be', [
'widthpx' => '150px',
'heightpx' => '150px',
]),
'required' => true,
'preview' => true,
])
</div>
</div>
</fieldset>
</div>
<div class="col-12 text-center">
<p><b>{{ __('validation.custom.required_fields') }}</b></p>
</div>
</div>
@push('scripts')
<script nonce="{{ $nonce }}">
document.addEventListener("DOMContentLoaded", () => {
// Update inputs for testimonialrs other than 'home'.
const testimonialrInput = document.getElementById('testimonialr');
const videoIdField = document.getElementById('video_id_input');
const titleInput = document.getElementById('testimonialTitle');
if (testimonialrInput.value === "{{ \App\Enums\Slides\SliderTypeEnum::home->value() }}") {
videoIdField.hidden = false;
titleInput.required = false;
} else {
videoIdField.hidden = true;
titleInput.required = true;
}
testimonialrInput.addEventListener('input', () => {
if (testimonialrInput.value === "{{ \App\Enums\Slides\SliderTypeEnum::home->value() }}") {
videoIdField.hidden = false;
titleInput.required = false;
} else {
videoIdField.hidden = true;
titleInput.required = true;
}
})
});
</script>
@endpush