206 lines
9.2 KiB
PHP
206 lines
9.2 KiB
PHP
<div class="form-group">
|
|
<label for="title"><small>{{ __('Titre*') }}</small></label>
|
|
<input id="title" type="text" class="form-control" name="title" placeholder="Titre *" value="{{ old('title') ?? $engagement->title ?? '' }}" required>
|
|
</div>
|
|
@if($engagement->type->equals(EngagementType::header()))
|
|
<div class="form-group">
|
|
<label class="col-form-label">{{ __('Contenu entête') }}*</label>
|
|
<custom-ckeditor name="content" dbtext="{{ old('content.header') ?? $engagement->content['header'] ?? '' }}"></custom-ckeditor>
|
|
</div>
|
|
@else
|
|
<div class="form-group">
|
|
<label for="metaTitle"><small>{{ __('Titre meta*') }}</small></label>
|
|
<input id="metaTitle" type="text" class="form-control" name="metaTitle" placeholder="Meta Titre *" minlength="20" maxlength="60" value="{{ old('metaTitle') ?? $engagement->metaTitle ?? '' }}" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="metaDescription"><small>{{ __('Description meta*') }}</small></label>
|
|
<input id="metaDescription" type="text" class="form-control" name="metaDescription" placeholder="Meta Description *" minlength="130" maxlength="160" value="{{ old('metaDescription') ?? $engagement->metaDescription ?? '' }}" required>
|
|
</div>
|
|
@php
|
|
$content = $engagement->content;
|
|
@endphp
|
|
@foreach ($content as $i => $bloc)
|
|
<hr>
|
|
<div>
|
|
<h3>Partie : {{ $bloc['type']['label'] }}</h3>
|
|
<div>
|
|
@foreach($bloc['content'] as $k => $input)
|
|
@if(!$loop->first)
|
|
<hr class="w-25">
|
|
@endif
|
|
@switch($input['inputType']['value'])
|
|
@case(InputType::url()->value)
|
|
@case(InputType::string()->value)
|
|
<div class="form-group">
|
|
<label for="{{ $i.$k }}"><small>{{ $input['label'] }}*</small></label>
|
|
<input id="{{ $i.$k }}" type="text" class="form-control" name="content[{{$i}}][content][{{$k}}][value]" placeholder="{{ $input['label'] }}" value="{{ old("content.$i.content.$k.value") ?? $input['value'] ?? '' }}" required>
|
|
</div>
|
|
@break
|
|
@case(InputType::text()->value)
|
|
<div class="form-group">
|
|
<label class="col-form-label">{{ $input['label'] }}*</label>
|
|
<custom-ckeditor name="content[{{$i}}][content][{{$k}}][value]" dbtext="{{ old("content.$i.content.$k.value") ?? $input['value'] ?? '' }}"></custom-ckeditor>
|
|
</div>
|
|
@break
|
|
@case(InputType::boolean()->value)
|
|
<div class="form-group">
|
|
<label>
|
|
<input type="checkbox" name="content[{{$i}}][content][{{$k}}][value]" value="1" @if (( old("content.$i.content.$k.value") ?? $input['value'] ?? 0 ))checked @endif>
|
|
{{ $input['label'] }}*
|
|
</label>
|
|
</div>
|
|
@break
|
|
@case(InputType::image()->value)
|
|
<div class="form-group">
|
|
<label for="{{ $i.$k }}img">Visuel * de type JPEG/PNG/SVG - 2Mo max. - {{ isset($input['dimensions']) ? __('Dimensions :dimensions', ['dimensions' => $input['dimensions']]) : __('Dimensions Maximales :max', ['max' => $input['dimensionsMax']]) }} px</label>
|
|
<input id="{{ $i.$k }}img" type="file" name="content[{{$i}}][content][{{$k}}][value]" accept="image/png,image/jpeg,.svg">
|
|
<br>
|
|
<label for="{{ $i.$k }}alt"><small>{{ $input['label'] }} - {{ __('Texte alternatif') }}</small></label>
|
|
<input id="{{ $i.$k }}alt" type="text" class="form-control" name="content[{{$i}}][content][{{$k}}][alt]" placeholder="{{ __('Texte alternatif à l\'image') }}" value="{{ old("content.$i.content.$k.alt") ?? $input['alt'] ?? '' }}">
|
|
<br>
|
|
@if(isset($input['value']) and strlen($input['value']))
|
|
<img src="{{ $input['value'] }}" alt="image" style="max-height: 200px;">
|
|
@endif
|
|
</div>
|
|
@break
|
|
@case(InputType::imageArray()->value)
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h6>{{ __('Images Infographie') }}</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
@include('bo.engagements.image-input', [
|
|
'i' => $i,
|
|
'k' => $k,
|
|
'tmpl' => true,
|
|
])
|
|
@foreach($input['value'] as $o => $image)
|
|
@include('bo.engagements.image-input', [
|
|
'i' => $i,
|
|
'k' => $k,
|
|
'o' => $o,
|
|
'tmpl' => false,
|
|
'image' => $image,
|
|
'input' => $input,
|
|
])
|
|
@endforeach
|
|
<div class="row d-flex justify-content-end">
|
|
<button class="btn btn-primary imageAdd">{{ __('Ajouter') }}</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@break
|
|
@case(InputType::labelArray()->value)
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h6>{{ __('Faits avec gros titres') }}</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
@include('bo.engagements.label-input', [
|
|
'i' => $i,
|
|
'k' => $k,
|
|
'tmpl' => true,
|
|
])
|
|
@foreach($input['value'] as $o => $label)
|
|
@include('bo.engagements.label-input', [
|
|
'i' => $i,
|
|
'k' => $k,
|
|
'o' => $o,
|
|
'tmpl' => false,
|
|
'label' => $label,
|
|
])
|
|
@endforeach
|
|
<div class="row d-flex justify-content-end">
|
|
<button class="btn btn-primary labelAdd">{{ __('Ajouter') }}</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@break
|
|
@default
|
|
@dump('unknown input type')
|
|
@endswitch
|
|
@endforeach
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
@endif
|
|
|
|
<hr>
|
|
@if(!$engagement->type->equals(EngagementType::header()))
|
|
<div class="form-group">
|
|
<label>
|
|
<input type="checkbox" name="status" value="1" @if ((old('status') ?? $engagement->status ?? 0))checked @endif>
|
|
{{ __('Page Publiée ?') }}
|
|
</label>
|
|
</div>
|
|
@push('scripts')
|
|
<script>
|
|
$(document).ready(function() {
|
|
var cloneFn = function(e) {
|
|
e.preventDefault();
|
|
$(this).parent().fadeOut(300, function() { this.remove(); });
|
|
};
|
|
var replaceID = function(c, attr) {
|
|
return attr.replace('[X]', '[' + lastId +']');
|
|
};
|
|
var setDataNumLabel = function(c , div) {
|
|
if($(div).hasClass('d-none')) {
|
|
return;
|
|
}
|
|
$(div).find('input').each(function(o, el) {
|
|
if (el.id.length) {
|
|
let xid = el.id.split('_');
|
|
xid[2] = c;
|
|
el.id = xid.join('_');
|
|
}
|
|
if ($(el).prev().attr('for')) {
|
|
let xfor = $(el).prev().attr('for').split('_');
|
|
xfor[2] = c;
|
|
$(el).prev().attr('for', xfor.join('_'));
|
|
}
|
|
$(el).attr('name', $(el).attr('name')
|
|
.replace(/(?:\[(X|[0-9]*)\])\[(fullLine|bigText|text)\]$/, '[' + (c-1) + '][$2]'));
|
|
});
|
|
};
|
|
var setDataNumImage = function(c , input) {
|
|
if(!c) {
|
|
return;
|
|
}
|
|
$(input).attr('name', $(input).attr('name')
|
|
.replace(/(\[(?:X|[0-9]*)\])$/, '[' + (c-1) + ']'));
|
|
};
|
|
$('.labelGroup,.imageGroup').each(function(k, grp) {
|
|
$(grp).children('button').first().on('click', cloneFn);
|
|
});
|
|
$('.labelAdd').on('click', function(e) {
|
|
e.preventDefault();
|
|
var $t = $($(this).parent().parent().find('.labelTemplate').first()).clone().removeClass('d-none');
|
|
var $self = $(this);
|
|
$t.insertBefore($(this).parent());
|
|
$t.children('button').first().on('click', cloneFn);
|
|
$self.parent().parent().find('div.alert').each(setDataNumLabel);
|
|
});
|
|
$('.labelAdd').parent().parent().on('click', 'button.close', function() {
|
|
var $self = $(this).parent().parent();
|
|
setTimeout(function() {
|
|
$self.find('div.alert').each(setDataNumLabel);
|
|
}, 400);
|
|
});
|
|
$('.imageAdd').on('click', function(e) {
|
|
e.preventDefault();
|
|
$t = $(this).parent().parent().find('.imageTemplate').first().clone().removeClass('d-none');
|
|
$t.insertBefore($(this).parent());
|
|
$t.find('input').first().attr('required', 'required');
|
|
$t.children('button').first().on('click', cloneFn);
|
|
$(this).parent().parent().find('input').each(setDataNumImage);
|
|
});
|
|
$('.imageAdd').parent().parent().on('click', 'button.close', function() {
|
|
var $self = $(this).parent().parent();
|
|
setTimeout(function() {
|
|
$self.find('input').each(setDataNumImage);
|
|
}, 400);
|
|
});
|
|
})
|
|
</script>
|
|
@endpush
|
|
@endif
|