lemo-crm/web/app/templates/components/input-select.hbs

50 lines
1.6 KiB
Handlebars

<select multiple={{multiple}}
data-placeholder={{placeholder}}
class="select2"
style="width: 100%;">
{{#if (and (not multiple) (and options.length nullable))}}
<option></option>
{{/if}}
{{#let (get model name) as |selected|}}
{{#each options as |opt|}}
{{#if (is-plain-val opt)}}
<option value={{opt}} data-option={{opt}}>
{{opt}}
</option>
{{else}}
{{#let (get opt value-field) as |val|}}
{{#unless (is-none val)}}
<option value={{val}}
data-option={{json-str opt}}
disabled={{if (and
(not (is-none enabled-field))
(not (get opt enabled-field))) 'disabled'}}>
{{option-text-exp
opt
value-field
text-field
text-exp}}
</option>
{{/unless}}
{{/let}}
{{/if}}
{{else}}
{{log 'select [' name '] has no options'}}
{{/each}}
{{/let}}
</select>
{{#if (and name hidden-input)}}
{{#let (get model name) as |val|}}
{{#if val}}
{{#if (is-array val)}}
{{#each val as |v|}}
<input type="hidden" name="{{name}}" value="{{v}}" />
{{/each}}
{{else}}
<input type="hidden" name="{{name}}" value="{{val}}" />
{{/if}}
{{/if}}
{{/let}}
{{/if}}