Add the ability to use a select list for template attributes
This commit is contained in:
parent
3ad4c446ea
commit
3bf97fc0d1
@ -69,6 +69,19 @@ class Template
|
|||||||
return collect($this->attributes->get($key));
|
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
|
* If the attribute has been marked as read-only
|
||||||
*
|
*
|
||||||
|
11
public/css/custom.css
vendored
11
public/css/custom.css
vendored
@ -14,11 +14,20 @@ attribute#objectclass .input-group-end:not(input.form-control) {
|
|||||||
z-index: 5;
|
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-bottom-right-radius: unset;
|
||||||
border-top-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 {
|
input.form-control.input-group-end {
|
||||||
border-bottom-right-radius: 4px !important;
|
border-bottom-right-radius: 4px !important;
|
||||||
border-top-right-radius: 4px !important;
|
border-top-right-radius: 4px !important;
|
||||||
|
@ -63,7 +63,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@switch($template?->attributeType($o->name))
|
@switch($template?->attributeType($o->name))
|
||||||
@case('type')
|
@case('select')
|
||||||
|
<x-attribute.template.select :o="$o" :template="$template" :edit="(! $template?->attributeReadOnly($o->name)) && $edit" :new="$new"/>
|
||||||
@break;
|
@break;
|
||||||
|
|
||||||
@default
|
@default
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
<!-- $o=Attribute::class -->
|
||||||
|
<x-attribute.layout :edit="$edit" :new="$new" :o="$o">
|
||||||
|
@foreach($o->langtags as $langtag)
|
||||||
|
@foreach(($o->tagValues($langtag)->count() ? $o->tagValues($langtag) : [$langtag => NULL]) as $key => $value)
|
||||||
|
@if($edit)
|
||||||
|
<div class="select-group">
|
||||||
|
<x-form.select
|
||||||
|
@class(['is-invalid'=>($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"/>
|
||||||
|
|
||||||
|
<div class="invalid-feedback pb-2">
|
||||||
|
@if($e=$errors->get($o->name_lc.'.'.$langtag.'.'.$loop->index))
|
||||||
|
{{ join('|',$e) }}
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
{{ $o->render_item_old($langtag.'.'.$key) }}
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
@endforeach
|
||||||
|
</x-attribute.layout>
|
Loading…
x
Reference in New Issue
Block a user