diff --git a/ui/admin/app/components/form/field/list-wrapper/index.hbs b/ui/admin/app/components/form/field/list-wrapper/index.hbs deleted file mode 100644 index edee33710..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/index.hbs +++ /dev/null @@ -1,33 +0,0 @@ -{{! - Copyright IBM Corp. 2021, 2026 - SPDX-License-Identifier: BUSL-1.1 -}} - - - - {{yield F to='fieldset'}} - - - {{yield - (hash - KeyValue=(component - 'form/field/list-wrapper/key-value' disabled=@disabled - ) - TextInput=(component - 'form/field/list-wrapper/text-input' disabled=@disabled - ) - Textarea=(component - 'form/field/list-wrapper/textarea' disabled=@disabled - ) - Select=(component 'form/field/list-wrapper/select' disabled=@disabled) - ) - to='field' - }} - - - \ No newline at end of file diff --git a/ui/admin/app/components/form/field/list-wrapper/key-value/index.hbs b/ui/admin/app/components/form/field/list-wrapper/key-value/index.hbs deleted file mode 100644 index a22714238..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/key-value/index.hbs +++ /dev/null @@ -1,202 +0,0 @@ -{{! - Copyright IBM Corp. 2021, 2026 - SPDX-License-Identifier: BUSL-1.1 -}} - -{{#let (unique-id) (unique-id) as |keyHeaderID valueHeaderID|}} - - <:head as |H|> - - - {{#if @keyLabel}} - {{@keyLabel}} - {{else}} - {{t 'form.key.label'}} - {{/if}} - - {{#if @valueLabel}} - {{@valueLabel}} - {{else}} - {{t 'form.value.label'}} - {{/if}} - - - {{t 'titles.actions'}} - - - - <:body as |B|> - {{#each this.options as |option index|}} - - - {{yield - (hash - text=(component - 'form/field/list-wrapper/key-value/text' - disabled=@disabled - value=option.key - ariaLabelledBy=keyHeaderID - setContext=(set-from-event option 'key') - ) - select=(component - 'form/field/list-wrapper/key-value/select' - disabled=@disabled - value=option.key - ariaLabelledBy=keyHeaderID - setContext=(set-from-event option 'key') - width=@width - ) - ) - to='key' - }} - - - - {{yield - (hash - text=(component - 'form/field/list-wrapper/key-value/text' - disabled=@disabled - value=option.value - ariaLabelledBy=valueHeaderID - setContext=(set-from-event option 'value') - ) - select=(component - 'form/field/list-wrapper/key-value/select' - disabled=@disabled - value=option.value - ariaLabelledBy=valueHeaderID - width=@width - setContext=(set-from-event option 'value') - ) - ) - to='value' - }} - - - - {{#if this.removeOptionByIndex}} - - {{/if}} - - - {{/each}} - {{#if this.showNewRow}} - - - {{#if (has-block 'newKey')}} - {{yield - (hash - text=(component - 'form/field/list-wrapper/key-value/text' - disabled=@disabled - value=this.newOptionKey - ariaLabelledBy=keyHeaderID - setContext=(set-from-event this 'newOptionKey') - ) - select=(component - 'form/field/list-wrapper/key-value/select' - disabled=@disabled - value=this.newOptionKey - ariaLabelledBy=keyHeaderID - width=@width - setContext=(set-from-event this 'newOptionKey') - ) - ) - to='newKey' - }} - - {{else}} - {{yield - (hash - text=(component - 'form/field/list-wrapper/key-value/text' - disabled=@disabled - value=this.newOptionKey - ariaLabelledBy=keyHeaderID - setContext=(set-from-event this 'newOptionKey') - ) - select=(component - 'form/field/list-wrapper/key-value/select' - disabled=@disabled - value=this.newOptionKey - ariaLabelledBy=keyHeaderID - width=@width - setContext=(set-from-event this 'newOptionKey') - ) - ) - to='key' - }} - {{/if}} - - - - {{#if (has-block 'newValue')}} - {{yield - (hash - text=(component - 'form/field/list-wrapper/key-value/text' - disabled=@disabled - value=this.newOptionValue - ariaLabelledBy=valueHeaderID - setContext=(set-from-event this 'newOptionValue') - ) - select=(component - 'form/field/list-wrapper/key-value/select' - disabled=@disabled - value=this.newOptionValue - ariaLabelledBy=valueHeaderID - width=@width - setContext=(set-from-event this 'newOptionValue') - ) - ) - to='newValue' - }} - - {{else}} - {{yield - (hash - text=(component - 'form/field/list-wrapper/key-value/text' - disabled=@disabled - value=this.newOptionValue - ariaLabelledBy=valueHeaderID - setContext=(set-from-event this 'newOptionValue') - ) - select=(component - 'form/field/list-wrapper/key-value/select' - disabled=@disabled - value=this.newOptionValue - ariaLabelledBy=valueHeaderID - width=@width - setContext=(set-from-event this 'newOptionValue') - ) - ) - to='value' - }} - {{/if}} - - - - - - - - {{/if}} - - -{{/let}} \ No newline at end of file diff --git a/ui/admin/app/components/form/field/list-wrapper/key-value/index.js b/ui/admin/app/components/form/field/list-wrapper/key-value/index.js deleted file mode 100644 index 404b8df80..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/key-value/index.js +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright IBM Corp. 2021, 2026 - * SPDX-License-Identifier: BUSL-1.1 - */ - -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; -import { set } from '@ember/object'; - -export default class MappingListComponent extends Component { - // =attributes - - /** - * @type {string} - */ - @tracked newOptionKey = ''; - - /** - * @type {string} - */ - @tracked newOptionValue = ''; - - /** - * Returns an array of key/value pair that the user enters - * @type {object} - */ - - get options() { - return this.args?.options || this.args?.model?.[this.args.name]; - } - - /** - * Determines if we need to show an empty row to the users to enter more key/value pairs based on removeDuplicates arg, - * by default it is true - * @type {object} - */ - get showNewRow() { - if (this.args.showNewRow) { - return this.args.showNewRow(); - } else { - return true; - } - } - - // =actions - - /** - * If a new key value is entered and an addOption method was specified, - * calls addOption with the new key and value. Resets key and value. - * Otherwise use the model argument to create the array and update the model - */ - - @action - addOption() { - if (this.args.addOption) { - if (this.newOptionKey) { - this.args.addOption({ - key: this.newOptionKey, - value: this.newOptionValue, - }); - } - } else { - const field = this.args.name; - const existingArray = this.args.model[field] ?? []; - - const newArray = [ - ...existingArray, - { key: this.newOptionKey, value: this.newOptionValue }, - ]; - set(this.args.model, field, newArray); - } - - this.newOptionKey = ''; - this.newOptionValue = ''; - } - - /** - * If removeOptionByIndex method was passed, use that. - * Otherwise, use the model to remove an option by index. We recreate a new array after - * splicing out the item so that ember is aware that the array has been modified. - * @param index {number} - */ - @action - removeOptionByIndex(index) { - if (this.args.removeOptionByIndex) { - this.args.removeOptionByIndex(index); - } else { - const field = this.args.name; - const newArray = this.args.model[field].filter((_, i) => i !== index); - set(this.args.model, field, newArray); - } - } -} diff --git a/ui/admin/app/components/form/field/list-wrapper/key-value/select.hbs b/ui/admin/app/components/form/field/list-wrapper/key-value/select.hbs deleted file mode 100644 index 5e39f7336..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/key-value/select.hbs +++ /dev/null @@ -1,24 +0,0 @@ -{{! - Copyright IBM Corp. 2021, 2026 - SPDX-License-Identifier: BUSL-1.1 -}} - - - - - {{#each @selectOptions as |selectOption|}} - - {{/each}} - - \ No newline at end of file diff --git a/ui/admin/app/components/form/field/list-wrapper/key-value/text.hbs b/ui/admin/app/components/form/field/list-wrapper/key-value/text.hbs deleted file mode 100644 index 2d7f1c5ba..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/key-value/text.hbs +++ /dev/null @@ -1,11 +0,0 @@ -{{! - Copyright IBM Corp. 2021, 2026 - SPDX-License-Identifier: BUSL-1.1 -}} - - \ No newline at end of file diff --git a/ui/admin/app/components/form/field/list-wrapper/select-text/index.hbs b/ui/admin/app/components/form/field/list-wrapper/select-text/index.hbs deleted file mode 100644 index 4fe653ccd..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/select-text/index.hbs +++ /dev/null @@ -1,116 +0,0 @@ -{{! - Copyright IBM Corp. 2021, 2026 - SPDX-License-Identifier: BUSL-1.1 -}} -{{#let (unique-id) (unique-id) as |keyHeaderID valueHeaderID|}} - - <:head as |H|> - - {{t 'form.key.label'}} - {{t 'form.value.label'}} - - {{t 'titles.actions'}} - - - - - <:body as |B|> - {{#each-in this.options as |select val|}} - - - - - {{#each-in @selectOptions as |key value|}} - - {{/each-in}} - - - - - - - - - - {{#if this.removeOptionByKey}} - - {{/if}} - - - {{/each-in}} - - {{#if this.showNewRow}} - - - - - - - {{#each-in this.selectOptions as |key value|}} - - {{/each-in}} - - - - - - - - - - - - - {{/if}} - - -{{/let}} \ No newline at end of file diff --git a/ui/admin/app/components/form/field/list-wrapper/select-text/index.js b/ui/admin/app/components/form/field/list-wrapper/select-text/index.js deleted file mode 100644 index 32a42df99..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/select-text/index.js +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright IBM Corp. 2021, 2026 - * SPDX-License-Identifier: BUSL-1.1 - */ - -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; -import { set } from '@ember/object'; - -export default class MappingListComponent extends Component { - // =attributes - - /** - * @type {string} - */ - @tracked newOptionKey = ''; - - /** - * @type {string} - */ - @tracked newOptionValue = ''; - - /** - * Returns an object of key/value pair that the user enters - * @type {object} - */ - get options() { - return this.args?.options || this.args?.model?.[this.args.name]; - } - - /** - * Determines if we need to show an empty row to the users to enter more key/value pairs based on removeDuplicates arg, - * by default it is true - * @type {object} - */ - get showNewRow() { - if (this.args.removeDuplicates) { - return ( - Object.keys(this.options || {}).length !== - Object.keys(this.args.selectOptions || {}).length - ); - } else { - return true; - } - } - - /** - * Prevents users from selecting duplicate keys from the select list if there's the arg is set to true - * @type {object} - */ - get selectOptions() { - const previouslySelectedKeys = Object.keys(this.options || {}); - if (this.args.removeDuplicates && previouslySelectedKeys.length) { - const newObj = { ...this.args.selectOptions }; - for (const key of Object.keys(newObj)) { - if (previouslySelectedKeys.includes(key)) { - delete newObj[key]; - } - } - return newObj; - } else { - return this.args.selectOptions; - } - } - // =actions - - /** - * Handles when then user makes changes to the select list - * @param oldkey {string} - * @param oldVal {string} - */ - @action - selectChange(oldkey, oldVal, { target: { value: newKey } }) { - const field = this.args.name; - const newObj = { ...this.args.model[field], [newKey]: oldVal }; - delete newObj[oldkey]; - set(this.args.model, field, newObj); - } - - /** - * Handles input changes - * @param key {string} - */ - @action - updateInput(key, { target: { value: newValue } }) { - const field = this.args.name; - this.args.model[field] = { - ...this.args.model[field], - [key]: newValue, - }; - } - - /** - * If a new key value is entered and an addOption method was specified, - * calls addOption with the new key and value. Resets key and value. - * Otherwise use the model argument to create the array and update the model - */ - - @action - addOption() { - if (this.args.addOption) { - if (this.newOptionKey) { - this.args.addOption({ - key: this.newOptionKey, - value: this.newOptionValue, - }); - } - } else { - const field = this.args.name; - this.args.model[field] = { - ...this.args.model[field], - [this.newOptionKey]: this.newOptionValue, - }; - } - - this.newOptionKey = ''; - this.newOptionValue = ''; - } - - /** - * If removeOptionByIndex method was passed, use that. - * Otherwise, use the model to remove an option by key - * @param index {number} - */ - @action - removeOptionByKey(selectedKey) { - if (this.args.removeOptionByKey) { - this.args.removeOptionByKey(selectedKey); - } else { - const field = this.args.name; - const newObj = { ...this.args.model[field] }; - delete newObj[selectedKey]; - set(this.args.model, field, newObj); - } - } -} diff --git a/ui/admin/app/components/form/field/list-wrapper/select/index.hbs b/ui/admin/app/components/form/field/list-wrapper/select/index.hbs deleted file mode 100644 index 23f18c5b3..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/select/index.hbs +++ /dev/null @@ -1,90 +0,0 @@ -{{! - Copyright IBM Corp. 2021, 2026 - SPDX-License-Identifier: BUSL-1.1 -}} - - - - <:body as |B|> - - {{#each this.options as |select index|}} - - - - - {{#each @selectOptions as |selectOption|}} - - {{/each}} - - - - - - {{#if this.removeOptionByIndex}} - - {{/if}} - - - {{/each}} - - - - - - - - {{#each @selectOptions as |selectOption|}} - - {{/each}} - - - - - - - - - - - \ No newline at end of file diff --git a/ui/admin/app/components/form/field/list-wrapper/select/index.js b/ui/admin/app/components/form/field/list-wrapper/select/index.js deleted file mode 100644 index 1ee8af360..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/select/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright IBM Corp. 2021, 2026 - * SPDX-License-Identifier: BUSL-1.1 - */ - -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; -import { set } from '@ember/object'; - -export default class MappingListSelectComponent extends Component { - // =attributes - - /** - * @type {string} - */ - @tracked newOptionValue = ''; - - get options() { - return this.args.options || this.args.model[this.args.name]; - } - - /** - * If a new input is entered and an addOption method was specified, - * calls addOption with the new input. Resets previous value. - * Otherwise use the model argument to create the array and update the model - */ - - @action - addOption() { - if (this.args.addOption && this.newOptionValue) { - this.args.addOption({ - value: this.newOptionValue, - }); - } else { - const field = this.args.name; - const existingArray = this.args.model[field] ?? []; - const newArray = [...existingArray, { value: this.newOptionValue }]; - set(this.args.model, field, newArray); - } - - this.newOptionValue = ''; - } - - /** - * If removeOptionByIndex method was passed, use that. - * Otherwise, use the model to remove an option by index. We recreate a new array after - * splicing out the item so that ember is aware that the array has been modified. - * @param index {number} - */ - @action - removeOptionByIndex(index) { - if (this.args.removeOptionByIndex) { - this.args.removeOptionByIndex(index); - } else { - const field = this.args.name; - const newArray = this.args.model[field].filter((_, i) => i !== index); - set(this.args.model, field, newArray); - } - } -} diff --git a/ui/admin/app/components/form/field/list-wrapper/text-input/index.hbs b/ui/admin/app/components/form/field/list-wrapper/text-input/index.hbs deleted file mode 100644 index 6b616a536..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/text-input/index.hbs +++ /dev/null @@ -1,62 +0,0 @@ -{{! - Copyright IBM Corp. 2021, 2026 - SPDX-License-Identifier: BUSL-1.1 -}} - - - - <:body as |B|> - - {{#each @options as |option index|}} - - - - - - - {{#if this.removeOptionByIndex}} - - {{/if}} - - - {{/each}} - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ui/admin/app/components/form/field/list-wrapper/text-input/index.js b/ui/admin/app/components/form/field/list-wrapper/text-input/index.js deleted file mode 100644 index fadf3c3a6..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/text-input/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright IBM Corp. 2021, 2026 - * SPDX-License-Identifier: BUSL-1.1 - */ - -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; -import { set } from '@ember/object'; - -export default class MappingListTextInputComponent extends Component { - // =attributes - - /** - * @type {string} - */ - @tracked newOptionValue = ''; - - // =actions - - /** - * If a new input is entered and an addOption method was specified, - * calls addOption with the new input. Resets previous value. - * Otherwise use the model argument to create the array and update the model - */ - - @action - addOption() { - if (this.args.addOption) { - if (this.newOptionValue) { - this.args.addOption({ - value: this.newOptionValue, - }); - } - } else { - const field = this.args.name; - const existingArray = this.args.model[field] ?? []; - const newArray = [...existingArray, { value: this.newOptionValue }]; - set(this.args.model, field, newArray); - } - - this.newOptionValue = ''; - } - - /** - * If removeOptionByIndex method was passed, use that. - * Otherwise, use the model to remove an option by index. We recreate a new array after - * splicing out the item so that ember is aware that the array has been modified. - * @param index {number} - */ - @action - removeOptionByIndex(index) { - if (this.args.removeOptionByIndex) { - this.args.removeOptionByIndex(index); - } else { - const field = this.args.name; - const newArray = this.args.model[field].filter((_, i) => i !== index); - set(this.args.model, field, newArray); - } - } -} diff --git a/ui/admin/app/components/form/field/list-wrapper/textarea/index.hbs b/ui/admin/app/components/form/field/list-wrapper/textarea/index.hbs deleted file mode 100644 index 7177f4d91..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/textarea/index.hbs +++ /dev/null @@ -1,60 +0,0 @@ -{{! - Copyright IBM Corp. 2021, 2026 - SPDX-License-Identifier: BUSL-1.1 -}} - - - - <:body as |B|> - - {{#each @options as |option index|}} - - - - - - - {{#if this.removeOptionByIndex}} - - {{/if}} - - - {{/each}} - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ui/admin/app/components/form/field/list-wrapper/textarea/index.js b/ui/admin/app/components/form/field/list-wrapper/textarea/index.js deleted file mode 100644 index aedc6c13a..000000000 --- a/ui/admin/app/components/form/field/list-wrapper/textarea/index.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright IBM Corp. 2021, 2026 - * SPDX-License-Identifier: BUSL-1.1 - */ - -import Component from '@glimmer/component'; -import { tracked } from '@glimmer/tracking'; -import { action } from '@ember/object'; -import { set } from '@ember/object'; - -export default class MappingListTextAreaComponent extends Component { - // =attributes - - /** - * @type {string} - */ - @tracked newOptionValue = ''; - - // =actions - - /** - * If a new input is entered and an addOption method was specified, - * calls addOption with the new input. Resets previous value. - * Otherwise use the model argument to create the array and update the model - */ - - @action - addOption() { - if (this.args.addOption) { - if (this.newOptionValue) { - this.args.addOption({ - value: this.newOptionValue, - }); - } - } else { - const field = this.args.name; - const existingArray = this.args.model[field] ?? []; - const newArray = [...existingArray, { value: this.newOptionValue }]; - set(this.args.model, field, newArray); - } - - this.newOptionValue = ''; - } - - /** - * If removeOptionByIndex method was passed, use that. - * Otherwise, use the model to remove an option by index. We recreate a new array after - * splicing out the item so that ember is aware that the array has been modified. - * @param index {number} - */ - @action - removeOptionByIndex(index) { - if (this.args.removeOptionByIndex) { - this.args.removeOptionByIndex(index); - } else { - const field = this.args.name; - const newArray = this.args.model[field].filter((_, i) => i !== index); - set(this.args.model, field, newArray); - } - } -} diff --git a/ui/admin/tests/integration/components/form/field/list-wrapper-test.js b/ui/admin/tests/integration/components/form/field/list-wrapper-test.js deleted file mode 100644 index f667ed1b6..000000000 --- a/ui/admin/tests/integration/components/form/field/list-wrapper-test.js +++ /dev/null @@ -1,305 +0,0 @@ -/** - * Copyright IBM Corp. 2021, 2026 - * SPDX-License-Identifier: BUSL-1.1 - */ - -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { click, findAll, render, select } from '@ember/test-helpers'; -import { hbs } from 'ember-cli-htmlbars'; -import { setupIntl } from 'ember-intl/test-support'; - -module('Integration | Component | list-wrapper', function (hooks) { - setupRenderingTest(hooks); - setupIntl(hooks, 'en-us'); - - test('it renders fields', async function (assert) { - this.set('label', 'Label'); - this.set('helperText', 'Help'); - this.set('error', 'Error!'); - - await render(hbs` - - <:fieldset as |F|> - - {{this.label}} - - - {{this.helperText}} - - - {{this.error}} - - - <:field as |F|> - - - - - `); - - assert.dom('tbody tr').exists({ count: 1 }); - assert.dom('legend').exists().hasText('Label'); - assert.dom('.hds-form-helper-text').exists().hasText('Help'); - - assert.dom('.hds-form-error__message').exists().hasText('Error!'); - assert.dom('button').exists().hasText('Add'); - }); - - test('it renders multiple options with key value pair', async function (assert) { - this.options = [ - { key: 'one', value: 'two' }, - { key: 'three', value: 'four' }, - ]; - - await render(hbs` - - <:field as |F|> - - <:key as |K|> - - - <:value as |V|> - - - - - - `); - - assert.dom('tbody tr').exists({ count: 3 }); - }); - - test('it renders multiple options with a single text field', async function (assert) { - this.options = [{ value: 'one' }, { value: 'three' }]; - - await render(hbs` - - - <:field as |F|> - - - - - `); - - assert - .dom('.list-wrapper-field [data-test-remove-button]') - .exists({ count: 2 }); - - assert.dom('tbody tr').exists({ count: 3 }); - }); - - test('it renders multiple options with a single textarea field', async function (assert) { - this.options = [{ value: 'one' }, { value: 'three' }]; - - await render(hbs` - - - <:field as |F|> - - - - - `); - - assert - .dom('.list-wrapper-field [data-test-remove-button]') - .exists({ count: 2 }); - - assert.dom('tbody tr').exists({ count: 3 }); - }); - - test('it renders multiple options with a single select field', async function (assert) { - this.set('options', ['option1', 'option2', 'option3']); - this.set('model', { select: [{ value: 'option2' }, { value: 'option3' }] }); - await render(hbs` - - - <:field as |F|> - - - - `); - - assert - .dom( - `.list-wrapper-field [data-test-remove-option-button=${this.model.select[0].value}]`, - ) - .exists({ count: 1 }); - - assert.dom('tbody tr').exists({ count: 3 }); - }); - - test('select field allows you to add and remove options', async function (assert) { - this.set('options', ['option1', 'option2', 'option3']); - this.set('model', { select: [{ value: 'option2' }, { value: 'option3' }] }); - await render(hbs` - - - <:field as |F|> - - - - `); - - assert.dom('tbody tr').exists({ count: 3 }); - - // Add an option - await select('.list-wrapper-field tbody tr:last-child select', 'option1'); - await click('.list-wrapper-field [data-test-add-option-button]'); - assert.dom('tbody tr').exists({ count: 4 }); - - // Remove an option - await click('.list-wrapper-field [data-test-remove-option-button=option1]'); - assert.dom('tbody tr').exists({ count: 3 }); - }); - - test('it renders multiple options with select and text input as key value pair', async function (assert) { - this.options = [ - { - key: 'username_attribute', - value: 'user', - }, - { - key: 'password_attribute', - value: 'pass', - }, - ]; - - this.selectOptions = ['username_attribute', 'password_attribute']; - - await render(hbs` - - <:field as |F|> - - <:key as |K|> - - - <:value as |V|> - - - - - - `); - - assert.dom('tbody tr').exists({ count: 1 }); - }); - - test('it does not render new rows when the select option limit is reached when showNewRow is passed', async function (assert) { - this.options = [ - { key: 'username_attribute', value: 'user' }, - { key: 'password_attribute', value: 'pass' }, - ]; - - this.selectOptions = ['username_attribute', 'password_attribute']; - this.showNewRow = () => false; - await render(hbs` - - <:field as |F|> - - <:key as |K|> - - - <:value as |V|> - - - - - - `); - - assert.dom('tbody tr').exists({ count: 2 }); - }); - - test('it does render unlimited new rows when @showNewRow is not passed', async function (assert) { - this.options = [ - { - key: 'username_attribute', - value: 'user', - }, - { - key: 'password_attribute', - value: 'pass', - }, - ]; - this.selectOptions = ['username_attribute', 'password_attribute']; - await render(hbs` - - <:field as |F|> - - <:key as |K|> - - - <:value as |V|> - - - - - - `); - - assert.dom('tbody tr').exists({ count: 3 }); - }); - - test('it renders `newKey` and `newValue` named blocks when passed instead of key and value blocks', async function (assert) { - this.options = ['option1', 'option2', 'option3']; - this.selectOptionsNewValue = [ - 'username_attribute_new_val', - 'password_attribute_new_val', - ]; - - this.selectOptionsNewKey = [ - 'username_attribute_new_key', - 'password_attribute_new_key', - ]; - await render(hbs` - - <:field as |F|> - - <:key as |K|> - - - <:newKey as |N|> - - - <:newValue as |S|> - - - <:value as |V|> - - - - - - `); - - assert.strictEqual( - findAll('.list-wrapper-field tbody td:nth-of-type(1) select option') - .length, - 3, - ); - assert.strictEqual( - findAll('.list-wrapper-field tbody td:nth-of-type(2) select option') - .length, - 3, - ); - }); -});