diff --git a/app/Classes/Template.php b/app/Classes/Template.php index a17476f1..657a132f 100644 --- a/app/Classes/Template.php +++ b/app/Classes/Template.php @@ -69,6 +69,19 @@ class Template return collect($this->attributes->get($key)); } + /** + * Return an template attributes select options + * + * @param string $attribute + * @return Collection|NULL + */ + public function attributeOptions(string $attribute): Collection|NULL + { + return ($x=$this->attribute($attribute)?->get('options')) + ? collect($x)->map(fn($item,$key)=>['id'=>$key,'value'=>$item]) + : NULL; + } + /** * If the attribute has been marked as read-only * diff --git a/public/css/custom.css b/public/css/custom.css index 0104ad4c..fe843a7b 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -14,11 +14,20 @@ attribute#objectclass .input-group-end:not(input.form-control) { z-index: 5; } -.input-group:first-child .select2-container--bootstrap-5 .select2-selection { +/* select forms that have nothing next to them */ +.select-group:first-child .select2-container--bootstrap-5 .select2-selection { + border-radius: 4px !important; +} + +.input-group:first-child:not(.select-group) .select2-container--bootstrap-5 .select2-selection { border-bottom-right-radius: unset; border-top-right-radius: unset; } +.select2-container .select2-selection--single .select2-selection__rendered { + font-size: 0.88em; +} + input.form-control.input-group-end { border-bottom-right-radius: 4px !important; border-top-right-radius: 4px !important; diff --git a/resources/views/components/attribute-type.blade.php b/resources/views/components/attribute-type.blade.php index 49740f91..e1bba96a 100644 --- a/resources/views/components/attribute-type.blade.php +++ b/resources/views/components/attribute-type.blade.php @@ -63,7 +63,8 @@ @switch($template?->attributeType($o->name)) - @case('type') + @case('select') + @break; @default diff --git a/resources/views/components/attribute/template/select.blade.php b/resources/views/components/attribute/template/select.blade.php new file mode 100644 index 00000000..efbaffec --- /dev/null +++ b/resources/views/components/attribute/template/select.blade.php @@ -0,0 +1,28 @@ + + + @foreach($o->langtags as $langtag) + @foreach(($o->tagValues($langtag)->count() ? $o->tagValues($langtag) : [$langtag => NULL]) as $key => $value) + @if($edit) +
+ ($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)),'mb-1','border-focus'=>! $o->tagValuesOld($langtag)->contains($value)]) + id="{{ $o->name_lc }}_{{$loop->index}}{{$template?->name ?: ''}}" + name="{{ $o->name_lc }}[{{ $langtag }}][]" + :value="$value" + :options="$template->attributeOptions($o->name_lc)" + allowclear="true" + :disabled="! $new" + :readonly="FALSE"/> + +
+ @if($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index)) + {{ join('|',$e) }} + @endif +
+
+ @else + {{ $o->render_item_old($langtag.'.'.$key) }} + @endif + @endforeach + @endforeach +
\ No newline at end of file