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

43 lines
1.2 KiB
Handlebars

<div
class="child-selector {{type}}-child-selector"
...attributes
>
{{yield}}
<YieldSlot @name="create">{{yield}}</YieldSlot>
<label class="type-text">
<span><YieldSlot @name="label">{{yield}}</YieldSlot></span>
{{#if isOpen}}
<DataSource
@src={{concat '/' (or nspace 'default') '/' 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={{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 (gt items.length 0)}}
<YieldSlot @name="set">{{yield}}</YieldSlot>
{{else}}
{{/if}}
</div>