Skip to content

Commit

Permalink
Hide the empty footer on the modal version of the view form
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Dec 14, 2021
1 parent 9c285b0 commit 03cbe45
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ describe('c-view-and-edit-form', () => {
expect( editForm ).toBe( null );
});

// TODO: clicking the buttons...

// TODO: clicking the buttons...
// TODO: clicking the modal cancel...

it('When visible modal and inEditMode, has a save and cancel button, but no edit', () => {
const element = createElement('c-view-and-edit-form', {
Expand All @@ -113,9 +113,13 @@ describe('c-view-and-edit-form', () => {

const additionalEditButtons = element.shadowRoot.querySelector( 'slot[name="additionalEditButtons"' );
expect( additionalEditButtons ).not.toBe( null );

const modalFooter = element.shadowRoot.querySelector( '[slot="footer"]' );
expect( modalFooter ).not.toBe( null );

});

it('When visible modal and not inEditMode, has an edit button, but no save or cancel', () => {
it('When visible modal and not inEditMode, has an edit button, but no save or cancel', () => {
const element = createElement('c-view-and-edit-form', {
is: ViewAndEditForm
});
Expand All @@ -138,6 +142,9 @@ describe('c-view-and-edit-form', () => {

const additionalEditButtons = element.shadowRoot.querySelector( 'slot[name="additionalEditButtons"' );
expect( additionalEditButtons ).toBe( null );

const modalFooter = element.shadowRoot.querySelector( '[slot="footer"]' );
expect( modalFooter ).toBe( null );
});

it('When visible modal and inEditMode, has an editForm slot but no viewForm slot', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<c-modal
visible={visible}
oncancel={handleCancelModalClick}
hide-footer={hideModalFooter}
>
<!-- TODO - new event for Cancel Modal Click-->

<div slot="title">
<slot name="title"></slot>
Expand All @@ -28,7 +28,6 @@
></lightning-button>
</lightning-button-group>


<slot name="viewForm"></slot>

</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default class ViewAndEditForm extends LightningElement {

@api displayDensity;

get hideModalFooter() {
return ! this.inEditMode;
}

render() {
return templates[ this.mode ];
}
Expand All @@ -45,4 +49,9 @@ export default class ViewAndEditForm extends LightningElement {
const newEvent = new CustomEvent( 'cancel' );
this.dispatchEvent( newEvent );
}

handleCancelModalClick( event ) {
const newEvent = new CustomEvent( 'cancelModal' );
this.dispatchEvent( newEvent );
}
}

0 comments on commit 03cbe45

Please sign in to comment.