open-consul/ui/packages/consul-ui/app/components/child-selector/index.hbs

45 lines
1.3 KiB
Handlebars

<div
class="child-selector {{type}}-child-selector"
...attributes
>
{{yield}}
{{#if (not disabled)}}
<YieldSlot @name="create">{{yield}}</YieldSlot>
<label class="type-text">
<span><YieldSlot @name="label">{{yield}}</YieldSlot></span>
{{#if isOpen}}
<DataSource
@src={{concat '/' nspace '/' dc '/' (pluralize type)}}
@onchange={{action (mut allOptions) value="data"}}
/>
{{/if}}
<DataCollection
@type={{type}}
@sort='Name:asc'
@filters={{hash
searchproperties=(array 'Name')
}}
@items={{options}}
as |collection|>
<PowerSelect
@searchEnabled={{true}}
@search={{action collection.search}}
@options={{sort-by 'Name:asc' options}}
@loadingMessage="Loading..."
@searchMessage="No possible options"
@searchPlaceholder={{placeholder}}
@onOpen={{action (mut isOpen) true}}
@onClose={{action (mut isOpen) false}}
@onChange={{action "change" "items[]" items}}
as |item|>
<YieldSlot @name="option" @params={{block-params item}}>{{yield}}</YieldSlot>
</PowerSelect>
</DataCollection>
</label>
{{/if}}
{{#if (gt items.length 0)}}
<YieldSlot @name="set">{{yield}}</YieldSlot>
{{else}}
{{/if}}
</div>