From 317ae3db68a742560bddd4d05be35906f28b4a62 Mon Sep 17 00:00:00 2001 From: Suzana Dirla Date: Mon, 24 Jun 2019 19:39:06 +0300 Subject: [PATCH] [ADF-4696] Display name on metadata card (#4870) * [ADF-4696] Display names on content metadata * [ADF-4696] unit test --- .../card-view-textitem.component.spec.ts | 15 +++++++++++++++ .../card-view/models/card-view-baseitem.model.ts | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts b/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts index 2c0c2d424c..9a9327f5a6 100644 --- a/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts +++ b/lib/core/card-view/components/card-view-textitem/card-view-textitem.component.spec.ts @@ -62,6 +62,21 @@ describe('CardViewTextItemComponent', () => { expect(value.nativeElement.innerText.trim()).toBe('Lorem ipsum'); }); + it('should render the displayName as value when available', () => { + let componentWithDisplayName: CardViewTextItemComponent; + componentWithDisplayName = fixture.componentInstance; + componentWithDisplayName.property = new CardViewTextItemModel({ + label: 'Name label', + value: {id: 123, displayName: 'User Name'}, + key: 'namekey' + }); + fixture.detectChanges(); + + const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`)); + expect(value).not.toBeNull(); + expect(value.nativeElement.innerText.trim()).toBe('User Name'); + }); + it('should NOT render the default as value if the value is empty, editable is false and displayEmpty is false', () => { component.property = new CardViewTextItemModel({ label: 'Text label', diff --git a/lib/core/card-view/models/card-view-baseitem.model.ts b/lib/core/card-view/models/card-view-baseitem.model.ts index 74f48ea8e0..5c09e0a217 100644 --- a/lib/core/card-view/models/card-view-baseitem.model.ts +++ b/lib/core/card-view/models/card-view-baseitem.model.ts @@ -30,7 +30,7 @@ export abstract class CardViewBaseItemModel { constructor(cardViewItemProperties: CardViewItemProperties) { this.label = cardViewItemProperties.label || ''; - this.value = cardViewItemProperties.value; + this.value = cardViewItemProperties.value && cardViewItemProperties.value.displayName || cardViewItemProperties.value; this.key = cardViewItemProperties.key; this.default = cardViewItemProperties.default; this.editable = !!cardViewItemProperties.editable;