[ADF-2614] Edit icon misses in Info-drawer Assignee (#3145)

* [DW-488] Edit icon misses in Info-drawer Assignee

* * Added unit testcases for the recent changes .

* * Updated card-view doc for the recent changes made.

* * Fixed failing taskHeader testcases
This commit is contained in:
siva kumar
2018-04-06 17:19:38 +05:30
committed by Denys Vuika
parent 38f2973863
commit 313d7f30cf
10 changed files with 85 additions and 5 deletions

View File

@@ -5,9 +5,12 @@
<span *ngIf="showProperty()">{{ property.displayValue }}</span>
</span>
<ng-template #elseBlock>
<span class="adf-textitem-clickable-value" (click)="clicked()" [attr.data-automation-id]="'card-textitem-value-' + property.key">
<div class="adf-textitem-clickable" (click)="clicked()" fxLayout="row" fxLayoutAlign="space-between center">
<span class="adf-textitem-clickable-value" [attr.data-automation-id]="'card-textitem-value-' + property.key">
<span *ngIf="showProperty(); else elseEmptyValueBlock">{{ property.displayValue }}</span>
</span>
<mat-icon *ngIf="hasIcon()" fxFlex="0 0 auto" [attr.data-automation-id]="'card-textitem-edit-icon-' + property.icon" class="adf-textitem-icon">{{ property.icon }}</mat-icon>
</div>
</ng-template>
</span>
<span *ngIf="isEditable()">

View File

@@ -24,6 +24,12 @@
}
}
&-textitem-clickable {
&:hover mat-icon {
opacity: 1;
}
}
&-textitem-clickable-value {
cursor: pointer;
color: mat-color($primary);

View File

@@ -185,6 +185,51 @@ describe('CardViewTextItemComponent', () => {
expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY');
});
it('should render the edit icon in case of clickable true and icon defined', () => {
component.property = new CardViewTextItemModel ({
label: 'Text label',
value: '',
key: 'textkey',
default: 'FAKE-DEFAULT-KEY',
clickable: true,
icon: 'FAKE-ICON'
});
fixture.detectChanges();
let value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
expect(value).not.toBeNull();
expect(value.nativeElement.innerText.trim()).toBe('FAKE-ICON');
});
it('should not render the edit icon in case of clickable true and icon undefined', () => {
component.property = new CardViewTextItemModel ({
label: 'Text label',
value: '',
key: 'textkey',
default: 'FAKE-DEFAULT-KEY',
clickable: true
});
fixture.detectChanges();
let value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
expect(value).toBeNull('Edit icon should NOT be shown');
});
it('should not render the edit icon in case of clickable false and icon defined', () => {
component.property = new CardViewTextItemModel ({
label: 'Text label',
value: '',
key: 'textkey',
default: 'FAKE-DEFAULT-KEY',
clickable: false,
icon: 'FAKE-ICON'
});
fixture.detectChanges();
let value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
expect(value).toBeNull('Edit icon should NOT be shown');
});
it('should render value when editable:true', () => {
component.editable = true;
component.property.editable = true;

View File

@@ -59,6 +59,10 @@ export class CardViewTextItemComponent implements OnChanges {
return this.property.clickable;
}
hasIcon(): boolean {
return !!this.property.icon;
}
hasErrors(): number {
return this.errorMessages && this.errorMessages.length;
}

View File

@@ -24,5 +24,6 @@ export interface CardViewItemProperties {
default?: any;
editable?: boolean;
clickable?: boolean;
icon?: string;
validators?: CardViewItemValidator[];
}

View File

@@ -23,4 +23,5 @@ export interface CardViewItem {
type: string;
displayValue: any;
editable?: boolean;
icon?: string;
}

View File

@@ -24,6 +24,7 @@ export abstract class CardViewBaseItemModel {
default: any;
editable: boolean;
clickable: boolean;
icon?: string;
validators?: CardViewItemValidator[];
constructor(obj: CardViewItemProperties) {
@@ -33,6 +34,7 @@ export abstract class CardViewBaseItemModel {
this.default = obj.default;
this.editable = !!obj.editable;
this.clickable = !!obj.clickable;
this.icon = obj.icon || '';
this.validators = obj.validators || [];
}