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

52 lines
1.4 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={{uri '/${partition}/${nspace}/${dc}/${type}'
(hash
partition=partition
nspace=nspace
dc=dc
type=(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>