Skip to content

Commit

Permalink
Updated ids to the standard in the view and edit form
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Jan 11, 2022
1 parent c5a1dd5 commit 897e31a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('c-view-and-edit-form', () => {
const saveButtons = element.shadowRoot.querySelector( 'c-save-buttons' );
expect( saveButtons ).not.toBe( null );

const editButton = element.shadowRoot.querySelector( '[data-name="edit"]' );
const editButton = element.shadowRoot.querySelector( '[data-ortoo-elem-id="viewandeditform-edit"]' );
expect( editButton ).toBe( null );

const additionalViewButtons = element.shadowRoot.querySelector( 'slot[name="additional-view-buttons"' );
Expand All @@ -41,7 +41,7 @@ describe('c-view-and-edit-form', () => {
const saveButtons = element.shadowRoot.querySelector( 'c-save-buttons' );
expect( saveButtons ).toBe( null );

const editButton = element.shadowRoot.querySelector( '[data-name="edit"]' );
const editButton = element.shadowRoot.querySelector( '[data-ortoo-elem-id="viewandeditform-edit"]' );
expect( editButton ).not.toBe( null );

const additionalViewButtons = element.shadowRoot.querySelector( 'slot[name="additional-view-buttons"' );
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('c-view-and-edit-form', () => {
return Promise.resolve()
.then( () => {
const clickEvent = new CustomEvent( 'click', {} );
return element.shadowRoot.querySelector( '[data-name="edit"]' ).click();
return element.shadowRoot.querySelector( '[data-ortoo-elem-id="viewandeditform-edit"]' ).click();
})
.then( () => {
expect( eventHandler ).toBeCalled();
Expand All @@ -156,7 +156,7 @@ describe('c-view-and-edit-form', () => {
const saveButtons = element.shadowRoot.querySelector( 'c-save-buttons' );
expect( saveButtons ).not.toBe( null );

const editButton = element.shadowRoot.querySelector( '[data-name="edit"]' );
const editButton = element.shadowRoot.querySelector( '[data-ortoo-elem-id="viewandeditform-edit"]' );
expect( editButton ).toBe( null );

const additionalViewButtons = element.shadowRoot.querySelector( 'slot[name="additional-view-buttons"' );
Expand All @@ -178,7 +178,7 @@ describe('c-view-and-edit-form', () => {
const saveButtons = element.shadowRoot.querySelector( 'c-save-buttons' );
expect( saveButtons ).toBe( null );

const editButton = element.shadowRoot.querySelector( '[data-name="edit"]' );
const editButton = element.shadowRoot.querySelector( '[data-ortoo-elem-id="viewandeditform-edit"]' );
expect( editButton ).not.toBe( null );

const additionalViewButtons = element.shadowRoot.querySelector( 'slot[name="additional-view-buttons"' );
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('c-view-and-edit-form', () => {
return Promise.resolve()
.then( () => {
const clickEvent = new CustomEvent( 'click', {} );
return element.shadowRoot.querySelector( '[data-name="edit"]' ).click();
return element.shadowRoot.querySelector( '[data-ortoo-elem-id="viewandeditform-edit"]' ).click();
})
.then( () => {
expect( eventHandler ).toBeCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
<slot name="additional-view-buttons"></slot>

<lightning-button
data-ortoo-elem-id={editId}
class="slds-m-top_small slds-float_right"
variant="default"
name="edit"
data-name="edit"
label={editLabel}
onclick={handleEditClick}
></lightning-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<c-modal
visible={visible}
oncancel={handleCancelModalClick}
ortoo-elem-id-prefix={modalId}
hide-footer={hideModalFooter}
>

Expand All @@ -15,10 +16,9 @@
<slot name="additional-view-buttons"></slot>

<lightning-button
data-ortoo-elem-id={editId}
class="slds-float_right"
variant="default"
name="edit"
data-name="edit"
label={editLabel}
onclick={handleEditClick}
></lightning-button>
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 cardTemplate from './viewAndEditForm-card.html';
import modalTemplate from './viewAndEditForm-modal.html';
Expand All @@ -20,7 +21,6 @@ export default class ViewAndEditForm extends LightningElement {
@api inEditMode = false;
@api visible = false;

// TODO: test these
@api editLabel = EDIT_LABEL;
@api cancelLabel = CANCEL_LABEL;
@api saveLabel = SAVE_LABEL;
Expand All @@ -42,6 +42,17 @@ export default class ViewAndEditForm extends LightningElement {
this._mode = value;
}

@api ortooElemIdPrefix = 'viewandeditform';

ortooIdConfiguration = {
modalId: '',
editId: 'edit'
}

connectedCallback() {
configureElementIdGenerator( this );
}

render() {
return templates[ this.mode ];
}
Expand Down

0 comments on commit 897e31a

Please sign in to comment.