266 lines
14 KiB
PHP
266 lines
14 KiB
PHP
{{-- MINI CRUD EDIT WHEN JSON IS TRANSLATABLE --}}
|
|
@php
|
|
$lastPrefix = null;
|
|
@endphp
|
|
@foreach ($data as $k => $input)
|
|
@if (!isset($input['inputType']))
|
|
@continue
|
|
@endif
|
|
|
|
@php
|
|
$prefix = str_contains($k, '_') ? explode('_', $k)[0] : null;
|
|
$displaySeparator = $lastPrefix !== null && $prefix !== $lastPrefix;
|
|
$lastPrefix = $prefix;
|
|
@endphp
|
|
|
|
@if ($displaySeparator)
|
|
<div class="my-4"></div>
|
|
@endif
|
|
|
|
@switch(intval($input['inputType']))
|
|
@case(intval(\App\Enums\InputType::string->value))
|
|
<div class="minicrud-input col-12 col-md-6 mb-3">
|
|
<fieldset class="h-100 border p-3">
|
|
<legend>{{ $input['label'] }} *</legend>
|
|
<div class="row">
|
|
<div class="col-12 mb-3">
|
|
@include('bo.partials.inputs.varchar', [
|
|
'id' => str($input['label'])->slug(),
|
|
'label' => $input['label'],
|
|
'hasWordCounter' => true,
|
|
'name' => 'data[' . $k . '][value]',
|
|
'value' => old("data.{$k}.value", $input['value'] ?? null),
|
|
'required' => isset($input['required']) ? !empty($input['required']) : true,
|
|
'model' => $model ?? null,
|
|
'helper' => __('validation.between.string', [
|
|
'attribute' => $input['label'],
|
|
'min' => 3,
|
|
'max' => 255,
|
|
]),
|
|
])
|
|
@include('modules.input-error', [
|
|
'inputName' => "data.{$k}.value",
|
|
])
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
@break
|
|
|
|
@case(intval(\App\Enums\InputType::number->value))
|
|
<div class="minicrud-input col-12 mb-3">
|
|
<fieldset class="mb-3 border p-3">
|
|
<div class="d-flex justify-content-start align-items-center mb-2 flex-row">
|
|
<legend class="m-0 w-auto">
|
|
<label class="col-form-label" for="number{{ $k }}">
|
|
<b>{{ $input['label'] }}</b>
|
|
</label>
|
|
</legend>
|
|
@if (!empty($input['tooltip']))
|
|
<span class="ms-1" data-bs-toggle="tooltip" data-bs-html="true" title="{{ $input['tooltip'] }}">
|
|
<i class="fa fa-question-circle"></i>
|
|
</span>
|
|
@endif
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="form-group">
|
|
<input class="form-control" id="number{{ $k }}" name="data[{{ $k }}][value]" type="number"
|
|
value="{{ old("data.{$k}.value") ?? ($input['value'] ?? '') }}" aria-describedby="NumberHelp{{ $k }}"
|
|
step="0.01" placeholder="{{ $input['label'] }}" @if (!isset($input['required']) or $input['required']) required @endif>
|
|
@include('modules.input-error', [
|
|
'inputName' => "data.{$k}.value",
|
|
'helperId' => "NumberHelp{$k}",
|
|
'helper' => $input['helper'] ?? '',
|
|
])
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
@break
|
|
|
|
@case(intval(\App\Enums\InputType::text->value))
|
|
<div class="minicrud-input col-12 mb-3">
|
|
<fieldset class="border p-3">
|
|
<legend>{{ $input['label'] }} *</legend>
|
|
<div class="row mb-3">
|
|
<div class="col-12">
|
|
@include('bo.partials.inputs.text-html', [
|
|
'id' => str($input['label'])->slug(),
|
|
'name' => "data[{$k}][value]",
|
|
'value' => old("data.{$k}.value", $input['value'] ?? null),
|
|
'model' => $model ?? null,
|
|
'helper' =>
|
|
__('crud.minicrud.text_warning') .
|
|
'. ' .
|
|
__('validation.min.string', [
|
|
'attribute' => $input['label'],
|
|
'min' => 3,
|
|
]),
|
|
])
|
|
@include('modules.input-error', [
|
|
'inputName' => "data.{$k}.value",
|
|
])
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
@break
|
|
|
|
@case(intval(\App\Enums\InputType::boolean->value))
|
|
<div class="minicrud-input col-12 col-md-6 mb-3">
|
|
<fieldset class="border p-3">
|
|
<legend>{{ $input['label'] }} *</legend>
|
|
<div class="row mb-3">
|
|
<div class="col-12">
|
|
<label class="col-form-label"
|
|
for="{{ str($input['label'])->slug() }}"><b>{{ __('crud.minicrud.visibility_label') }}</b></label>
|
|
<div class="form-check form-switch ms-2">
|
|
<input class="form-check-input ml-2" id="{{ str($input['label'])->slug() }}" name="data[{{ $k }}][value]"
|
|
type="checkbox" value="1" aria-describedby="{{ str($input['label'])->slug() }}Help"
|
|
@if (old("data.{$k}.value", old('_token') ? false : $input['value'] ?? (null ?? false))) checked @endif>
|
|
</div>
|
|
@include('modules.input-error', [
|
|
'inputName' => "data.{$k}.value",
|
|
'helperId' => str($input['label'])->slug() . 'Help',
|
|
'helper' => __('crud.minicrud.visibility_helper'),
|
|
])
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
@break
|
|
|
|
@case(intval(\App\Enums\InputType::image->value))
|
|
<div class="minicrud-input col-12 mb-3">
|
|
<fieldset class="h-100 border p-3">
|
|
<legend>{{ $input['label'] }} *</legend>
|
|
<div class="row">
|
|
{{-- PICTURE_ALT --}}
|
|
<div class="col-12 col-md-6 mb-3">
|
|
@include('bo.partials.inputs.varchar', [
|
|
'id' => str($input['label'])->slug() . '-alt',
|
|
'label' => __('crud.minicrud.picture_alt_label'),
|
|
'hasWordCounter' => true,
|
|
'name' => 'data[' . $k . '][alt]',
|
|
'value' => old("data.{$k}.alt", $input['alt'] ?? null),
|
|
'required' => is_bool($input['required'] ?? null) ? $input['required'] : true,
|
|
'model' => $model ?? null,
|
|
'helper' =>
|
|
__('crud.minicrud.picture_alt_helper') .
|
|
'. ' .
|
|
__('validation.min.string', [
|
|
'attribute' => __('crud.minicrud.picture_alt_label'),
|
|
'min' => 3,
|
|
]),
|
|
])
|
|
@include('modules.input-error', [
|
|
'inputName' => "data.{$k}.alt",
|
|
])
|
|
</div>
|
|
{{-- PICTURE_TITLE --}}
|
|
<div class="col-12 col-md-6 mb-3">
|
|
@include('bo.partials.inputs.varchar', [
|
|
'id' => str($input['label'])->slug() . '-title',
|
|
'label' => __('crud.minicrud.picture_title_label'),
|
|
'hasWordCounter' => true,
|
|
'name' => 'data[' . $k . '][title]',
|
|
'value' => old("data.{$k}.title", $input['title'] ?? null),
|
|
'required' => is_bool($input['required'] ?? null) ? $input['required'] : true,
|
|
'model' => $model ?? null,
|
|
'helper' =>
|
|
__('crud.minicrud.picture_title_helper') .
|
|
'. ' .
|
|
__('validation.min.string', [
|
|
'attribute' => __('crud.minicrud.picture_title_label'),
|
|
'min' => 3,
|
|
]),
|
|
])
|
|
@include('modules.input-error', [
|
|
'inputName' => "data.{$k}.title",
|
|
])
|
|
</div>
|
|
{{-- PICTURE --}}
|
|
<div class="col-12 mb-3">
|
|
@include('bo.partials.inputs.varchar-picture', [
|
|
'id' => str($input['label'])->slug(),
|
|
'name' => "data[{$k}][value]",
|
|
'width' => $input['dimensions']['width'],
|
|
'height' => $input['dimensions']['height'],
|
|
'model' => $model ?? null,
|
|
'value' => old("data.{$k}.value", $input['value'] ?? null),
|
|
'required' => is_bool($input['required'] ?? null) ? $input['required'] : true,
|
|
'preview' => true,
|
|
])
|
|
@include('modules.input-error', [
|
|
'inputName' => "data.{$k}.value",
|
|
])
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
@break
|
|
|
|
@case(\App\Enums\InputType::email->value)
|
|
<div class="minicrud-input col-12 col-md-6 mb-3">
|
|
<fieldset class="mb-3 border p-3">
|
|
<div class="d-flex justify-content-start align-items-center mb-2 flex-row">
|
|
<legend class="m-0 w-auto">
|
|
<label class="col-form-label" for="title{{ $k }}">
|
|
<b>{{ $input['label'] }}</b>
|
|
</label>
|
|
</legend>
|
|
@if (!empty($input['tooltip']))
|
|
<span class="ms-1" data-bs-toggle="tooltip" data-bs-html="true" title="{{ $input['tooltip'] }}">
|
|
<i class="fa fa-question-circle"></i>
|
|
</span>
|
|
@endif
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="form-group">
|
|
<input class="form-control" id="title{{ $k }}" name="data[{{ $k }}][value]" type="email"
|
|
value="{{ old("data.{$k}.value") ?? ($input['value'] ?? '') }}" placeholder="{{ $input['label'] }}"
|
|
@if (!isset($input['required']) or $input['required']) required @endif>
|
|
@include('modules.input-error', [
|
|
'inputName' => "data.{$k}.value",
|
|
'helperId' => "{$k}StringHelp",
|
|
'helper' => $input['helper'] ?? '',
|
|
])
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
@break
|
|
|
|
@case(intval(\App\Enums\InputType::url->value))
|
|
<div class="minicrud-input col-12 col-md-6 mb-3">
|
|
<fieldset class="h-100 border p-3">
|
|
<legend>{{ $input['label'] }} *</legend>
|
|
<div class="row">
|
|
<div class="col-12 mb-3">
|
|
@include('bo.partials.inputs.varchar', [
|
|
'id' => str($input['label'])->slug(),
|
|
'label' => $input['label'],
|
|
'hasWordCounter' => true,
|
|
'name' => 'data[' . $k . '][value]',
|
|
'value' => old("data.{$k}.value", $input['value'] ?? null),
|
|
'required' => isset($input['required']) ? !empty($input['required']) : true,
|
|
'model' => $model ?? null,
|
|
'helper' => __('validation.between.string', [
|
|
'attribute' => $input['label'],
|
|
'min' => 3,
|
|
'max' => 255,
|
|
]),
|
|
])
|
|
@include('modules.input-error', [
|
|
'inputName' => "data.{$k}.value",
|
|
])
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
@break
|
|
|
|
@default
|
|
@php throw new Exception('Input type not handled'); @endphp
|
|
@endswitch
|
|
@endforeach
|