2022-11-19 01:29:04 +00:00
|
|
|
<div
|
|
|
|
{{did-insert (perform this.fetchOptions)}}
|
|
|
|
id={{@id}}
|
|
|
|
class="field search-select {{if @displayInherit 'display-inherit'}}"
|
|
|
|
data-test-search-select-with-modal
|
|
|
|
...attributes
|
|
|
|
>
|
2022-07-27 21:18:22 +00:00
|
|
|
{{#if this.shouldUseFallback}}
|
|
|
|
{{component
|
|
|
|
@fallbackComponent
|
2022-10-03 18:01:34 +00:00
|
|
|
label=@label
|
2022-07-27 21:18:22 +00:00
|
|
|
subText=@subText
|
|
|
|
onChange=@onChange
|
|
|
|
inputValue=@inputValue
|
|
|
|
helpText=@helpText
|
2022-10-03 18:01:34 +00:00
|
|
|
placeholder=@placeholder
|
2022-07-27 21:18:22 +00:00
|
|
|
id=@id
|
|
|
|
}}
|
|
|
|
{{else}}
|
|
|
|
{{#if @label}}
|
2022-11-19 01:29:04 +00:00
|
|
|
<label for={{@id}} class={{or @labelClass "is-label"}} data-test-field-label>
|
2022-07-27 21:18:22 +00:00
|
|
|
{{@label}}
|
|
|
|
{{#if @helpText}}
|
|
|
|
<InfoTooltip>{{@helpText}}</InfoTooltip>
|
|
|
|
{{/if}}
|
|
|
|
</label>
|
|
|
|
{{/if}}
|
|
|
|
{{#if @subText}}
|
2022-11-19 01:29:04 +00:00
|
|
|
<p data-test-modal-subtext class="sub-text">{{@subText}}</p>
|
2022-07-27 21:18:22 +00:00
|
|
|
{{/if}}
|
2022-11-19 01:29:04 +00:00
|
|
|
{{#unless this.hidePowerSelect}}
|
2022-07-27 21:18:22 +00:00
|
|
|
<PowerSelect
|
|
|
|
@eventType="click"
|
|
|
|
@placeholder={{@placeholder}}
|
|
|
|
@searchEnabled={{true}}
|
|
|
|
@search={{this.searchAndSuggest}}
|
2022-11-19 01:29:04 +00:00
|
|
|
@options={{this.dropdownOptions}}
|
2022-07-27 21:18:22 +00:00
|
|
|
@onChange={{this.selectOrCreate}}
|
|
|
|
@placeholderComponent={{component "search-select-placeholder"}}
|
|
|
|
@verticalPosition="below"
|
|
|
|
as |option|
|
|
|
|
>
|
|
|
|
{{#if this.shouldRenderName}}
|
|
|
|
{{option.name}}
|
2022-11-19 01:29:04 +00:00
|
|
|
{{#unless option.__isSuggestion__}}
|
|
|
|
<small class="search-select-list-key" data-test-smaller-id="true">
|
|
|
|
{{option.id}}
|
|
|
|
</small>
|
|
|
|
{{/unless}}
|
2022-07-27 21:18:22 +00:00
|
|
|
{{else}}
|
|
|
|
{{option.id}}
|
|
|
|
{{/if}}
|
|
|
|
</PowerSelect>
|
|
|
|
{{/unless}}
|
|
|
|
<ul class="search-select-list">
|
2022-11-19 01:29:04 +00:00
|
|
|
{{#each this.selectedOptions as |selected index|}}
|
|
|
|
<li class="search-select-list-item" data-test-selected-option={{index}}>
|
2022-07-27 21:18:22 +00:00
|
|
|
{{#if this.shouldRenderName}}
|
|
|
|
{{selected.name}}
|
2022-11-19 01:29:04 +00:00
|
|
|
<small class="search-select-list-key" data-test-smaller-id={{index}}>
|
2022-07-27 21:18:22 +00:00
|
|
|
{{selected.id}}
|
|
|
|
</small>
|
|
|
|
{{else}}
|
|
|
|
<div>
|
|
|
|
{{selected.id}}
|
|
|
|
</div>
|
|
|
|
{{/if}}
|
|
|
|
<div class="control">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="button is-ghost"
|
|
|
|
data-test-selected-list-button="delete"
|
|
|
|
{{on "click" (fn this.discardSelection selected)}}
|
|
|
|
>
|
|
|
|
<Icon @name="trash" class="has-text-grey" />
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
{{/each}}
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
{{/if}}
|
2022-11-19 01:29:04 +00:00
|
|
|
|
|
|
|
{{! wait until user has selected 'create a new item' before rendering modal}}
|
|
|
|
{{#if this.nameInput}}
|
2022-07-27 21:18:22 +00:00
|
|
|
<Modal
|
2022-09-09 01:06:05 +00:00
|
|
|
@title="Create new {{singularize @id}}"
|
2022-07-27 21:18:22 +00:00
|
|
|
@onClose={{action (mut this.showModal) false}}
|
|
|
|
@isActive={{this.showModal}}
|
|
|
|
@type="info"
|
|
|
|
@showCloseButton={{false}}
|
|
|
|
>
|
|
|
|
<section class="modal-card-body">
|
2022-11-19 01:29:04 +00:00
|
|
|
{{#if @modalSubtext}}
|
|
|
|
<p class="has-bottom-margin-s" data-test-modal-subtext>
|
|
|
|
{{@modalSubtext}}
|
|
|
|
</p>
|
|
|
|
{{/if}}
|
2022-07-27 21:18:22 +00:00
|
|
|
{{#if (has-block)}}
|
|
|
|
{{yield}}
|
|
|
|
{{else}}
|
2022-11-19 01:29:04 +00:00
|
|
|
{{! dynamically render template from modal-form/ folder}}
|
2022-07-27 21:18:22 +00:00
|
|
|
{{! form must receive an @onSave and @onCancel arg that executes the callback}}
|
2022-11-19 01:29:04 +00:00
|
|
|
{{component @modalFormTemplate nameInput=this.nameInput onSave=this.resetModal onCancel=this.resetModal}}
|
2022-07-27 21:18:22 +00:00
|
|
|
{{/if}}
|
|
|
|
</section>
|
|
|
|
</Modal>
|
|
|
|
{{/if}}
|
|
|
|
</div>
|