Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 40 additions & 23 deletions ui/lib/core/addon/components/form-field.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,46 @@
<G.Error data-test-field-validation={{this.valuePath}}>{{this.validationError}}</G.Error>
{{/if}}
</Hds::Form::Checkbox::Group>
{{else}}
<Hds::Form::Select::Field
name={{@attr.name}}
@id={{@attr.name}}
{{on "change" this.onChangeWithEvent}}
data-test-input={{@attr.name}}
@isInvalid={{this.validationError}}
as |F|
>
{{#if this.labelString}}
<F.Label data-test-form-field-label>{{this.labelString}}</F.Label>
{{/if}}
{{#if this.showHelpText}}
<F.HelperText data-test-help-text>{{@attr.options.helpText}}</F.HelperText>
{{/if}}
{{#if @attr.options.subText}}
<F.HelperText data-test-label-subtext>
{{@attr.options.subText}}
{{#if @attr.options.docLink}}
<DocLink @path={{@attr.options.docLink}}>See our documentation</DocLink>
for help.
{{/if}}
</F.HelperText>
{{/if}}
<F.Options>
{{#if @attr.options.noDefault}}
<option value="">
Select one
</option>
{{/if}}
{{#each (path-or-array @attr.options.possibleValues @model) as |val|}}
<option selected={{loose-equal (get @model this.valuePath) (or val.value val)}} value={{or val.value val}}>
{{or val.displayName val}}
</option>
{{/each}}
</F.Options>
{{#if this.validationError}}
<F.Error data-test-field-validation={{this.valuePath}}>{{this.validationError}}</F.Error>
{{/if}}
</Hds::Form::Select::Field>
{{/if}}
{{/if}}
{{else}}
Expand Down Expand Up @@ -93,29 +133,6 @@
</div>
{{/each}}
</div>
{{else}}
<div class="control is-expanded">
<div class="select is-fullwidth">
<select
class="{{if this.validationError 'has-error-border'}}"
name={{@attr.name}}
id={{@attr.name}}
onchange={{this.onChangeWithEvent}}
data-test-input={{@attr.name}}
>
{{#if @attr.options.noDefault}}
<option value="">
Select one
</option>
{{/if}}
{{#each (path-or-array @attr.options.possibleValues @model) as |val|}}
<option selected={{loose-equal (get @model this.valuePath) (or val.value val)}} value={{or val.value val}}>
{{or val.displayName val}}
</option>
{{/each}}
</select>
</div>
</div>
{{/if}}
{{else if (eq @attr.options.editType "dateTimeLocal")}}
<Input
Expand Down
8 changes: 4 additions & 4 deletions ui/lib/core/addon/components/form-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ export default class FormFieldComponent extends Component {

// here we replicate the logic in the template, to make sure we don't change the order in which the "ifs" are evaluated
if (options?.possibleValues?.length > 0) {
if (options?.editType === 'checkboxList') {
return true;
} else {
// we still have to migrate the `radio` and `select` use cases
// we still have to migrate the `radio` use case
if (options?.editType === 'radio') {
return false;
} else {
return true;
}
} else {
if (type === 'number' || type === 'string') {
Expand Down
Loading