open-nomad/ui/app/templates/components/multi-select-dropdown.hbs

43 lines
1.3 KiB
Handlebars
Raw Normal View History

<BasicDropdown
@horizontalPosition="left"
@onOpen={{action (queue (action (mut isOpen) true) (action capture))}}
@onClose={{action (mut isOpen) false}} as |dd|
>
<dd.Trigger data-test-dropdown-trigger class="dropdown-trigger" {{on "keydown" (action "openOnArrowDown" dd)}}>
<div class="dropdown-trigger-label">
{{label}}
{{#if selection.length}}
<span data-test-dropdown-count class="tag is-light">
{{selection.length}}
</span>
{{/if}}
</div>
<span class="dropdown-trigger-icon ember-power-select-status-icon"></span>
</dd.Trigger>
<dd.Content class="dropdown-options">
<ul role="listbox" data-test-dropdown-options>
{{#each options key="key" as |option|}}
<li
data-test-dropdown-option={{option.key}}
class="dropdown-option"
tabindex="1"
onkeydown={{action "traverseList" option}}
>
<label>
<input
type="checkbox"
tabindex="-1"
checked={{contains option.key selection}}
onchange={{action "toggle" option}}
/>
{{option.label}}
</label>
</li>
2019-01-23 00:29:09 +00:00
{{else}}
<em data-test-dropdown-empty class="dropdown-empty">
No options
</em>
{{/each}}
</ul>
</dd.Content>
</BasicDropdown>