Skip to content

Commit

Permalink
Updated ids to the standard in the self configured combobox
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Jan 11, 2022
1 parent 897e31a commit 329af98
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,45 @@ describe('c-self-configured-combobox', () => {
expect( console.error ).not.toHaveBeenCalled();
});

it('when readonly, will show a field with the specified value', () => {
const element = createElement('c-self-configured-combobox', {
is: TestableSelfConfiguredCombobox
});
element.readOnly = true;
element.settableOptions = OPTIONS;
element.value = '0';
element.ortooElemIdPrefix = 'thefield';

document.body.appendChild(element);

const field = element.shadowRoot.querySelector( '[data-ortoo-elem-id="thefield"]' );
expect( field ).not.toBe( null );
expect( field.value ).toBe( 'Zero' );
});

it('when editable, will show a field with the specified value', () => {
const element = createElement('c-self-configured-combobox', {
is: TestableSelfConfiguredCombobox
});
element.readOnly = false;
element.settableOptions = OPTIONS;
element.value = '0';
element.ortooElemIdPrefix = 'thefield';

document.body.appendChild(element);

const field = element.shadowRoot.querySelector( '[data-ortoo-elem-id="thefield"]' );
expect( field ).not.toBe( null );
expect( field.value ).toBe( '0' );
});

it('when readonly, will pass the label, help text and display density into the readonlyfield', () => {
const element = createElement('c-self-configured-combobox', {
is: TestableSelfConfiguredCombobox
});
element.readOnly = true;
element.label = LABEL;
element.fieldLevelHelp = HELP_TEXT;
element.fieldLevelHelp = HELP_TEXT;
element.displayDensity = DISPLAY_DENSITY;

document.body.appendChild(element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<template if:true={readOnly}>
<c-read-only-field
data-ortoo-elem-id={fieldId}
label={label}
value={valueLabel}
field-level-help={fieldLevelHelp}
Expand All @@ -12,6 +13,7 @@
<template if:false={readOnly}>
<div class={fieldPadding}> <!-- can this be a constant?-->
<lightning-combobox
data-ortoo-elem-id={fieldId}
name={name}
label={label}
value={value}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LightningElement, api } from 'lwc';
import configureElementIdGenerator from 'c/elementIdGenerator';

import LAYOUT_CONSTANTS from 'c/layoutConstants';
export default class SelfConfiguredCombobox extends LightningElement {
Expand Down Expand Up @@ -32,6 +33,16 @@ export default class SelfConfiguredCombobox extends LightningElement {
this.configureValue();
}

@api ortooElemIdPrefix = 'combobox';

ortooIdConfiguration = {
fieldId: ''
}

connectedCallback() {
configureElementIdGenerator( this );
}

noOptionsErrorMessage;

currentValueIsNotAValidOption = 'The current value is not a valid option';
Expand Down

0 comments on commit 329af98

Please sign in to comment.