Hide buttons when no link associated

This commit is contained in:
Sebastien Hattry 2023-02-24 08:28:17 +00:00
parent 451a69151f
commit 82cefd1c4c
6 changed files with 21 additions and 11 deletions

View file

@ -129,9 +129,14 @@ class UpdateEngagement extends FormRequest
}//end if
break;
case InputType::url()->value:
if ($iptName === "link") {
$ruleAtt = "sometimes";
} else {
$ruleAtt = "required";
}
$rules = array_merge($rules, [
"content.$i.content.$iptName.value" => [
'required', 'url',
$ruleAtt, 'url',
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
function ($attribute, $value, $fail) {
try {
@ -172,10 +177,10 @@ class UpdateEngagement extends FormRequest
"content.$i.content.$iptName.value" => 'boolean'
]);
break;
}//end switch
}//end foreach
}//end foreach
}//end if
} //end switch
} //end foreach
} //end foreach
} //end if
return $rules;
}
}

View file

@ -32,8 +32,13 @@ $content = $engagement->content;
@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>
@if($k === 'link')
<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'] ?? '' }}">
@else
<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>
@endif
</div>
@break
@case(InputType::text()->value)

View file

@ -5,7 +5,7 @@
<div class="text ck-content">
{!! clean($bloc['content']['content']['value']) !!}
</div>
@if($bloc['content']['link']['status'])
@if($bloc['content']['link']['status'] && $bloc['content']['link']['value'] !== "")
<div class="link @if(!count($bloc['content']['labels']['value'])) noborder @endif">
<a href="{{ $bloc['content']['link']['value'] }}" @if($bloc['content']['link']['newtab']) target="_blank" @endif>{{ $bloc['content']['link']['text'] ?? __('En Savoir +') }}</a>
</div>

View file

@ -7,7 +7,7 @@
<div class="text ck-content">
{!! clean($bloc['content']['content']['value']) !!}
</div>
@if($bloc['content']['link']['status'])
@if($bloc['content']['link']['status'] && $bloc['content']['link']['value'] !== "")
<div class="link">
<a href="{{ $bloc['content']['link']['value'] }}" @if($bloc['content']['link']['newtab']) target="_blank" @endif>{{ $bloc['content']['link']['text'] ?? __('En Savoir +') }}</a>
</div>

View file

@ -5,7 +5,7 @@
<div class="text ck-content">
{!! clean($bloc['content']['content']['value']) !!}
</div>
@if($bloc['content']['link']['status'])
@if($bloc['content']['link']['status'] && $bloc['content']['link']['value'] !== "")
<div class="link @if(!count($bloc['content']['labels']['value'])) noborder @endif">
<a href="{{ $bloc['content']['link']['value'] }}" @if($bloc['content']['link']['newtab']) target="_blank" @endif>{{ $bloc['content']['link']['text'] ?? __('En Savoir +') }}</a>
</div>

View file

@ -5,7 +5,7 @@
<div class="text ck-content">
{!! clean($bloc['content']['content']['value']) !!}
</div>
@if($bloc['content']['link']['status'])
@if($bloc['content']['link']['status'] && $bloc['content']['link']['value'] !== "")
<div class="link noborder">
<a href="{{ $bloc['content']['link']['value'] }}" @if($bloc['content']['link']['newtab']) target="_blank" @endif>{{ $bloc['content']['link']['text'] ?? __('En Savoir +') }}</a>
</div>