Merge branch 'development' into next-release-3.2.0

This commit is contained in:
Eugenio Romano
2019-03-27 14:30:33 +00:00
committed by Eugenio Romano
120 changed files with 1583 additions and 13770 deletions

View File

@@ -1,5 +1,5 @@
.adf {
&-mapitem-clickable-value {
cursor: pointer;
cursor: pointer !important;
}
}

View File

@@ -5,12 +5,11 @@
<span *ngIf="showProperty()" class="adf-textitem-ellipsis">{{ property.displayValue }}</span>
</span>
<ng-template #elseBlock>
<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>
<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>
</div>
</ng-template>
</span>
<span *ngIf="isEditable()">

View File

@@ -17,7 +17,7 @@
}
&-textitem-readonly {
cursor: pointer;
cursor: pointer !important;
&:hover mat-icon {
opacity: 1;
@@ -31,7 +31,7 @@
}
&-textitem-clickable-value {
cursor: pointer;
cursor: pointer !important;
color: mat-color($primary);
}
@@ -42,7 +42,7 @@
mat-icon:not(.adf-button-disabled):hover {
opacity: 1;
cursor: pointer;
cursor: pointer !important;;
}
mat-form-field {

View File

@@ -157,7 +157,24 @@ 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', () => {
it('should render the edit icon in case of clickable true and editable true', () => {
component.property = new CardViewTextItemModel({
label: 'Text label',
value: '',
key: 'textkey',
default: 'FAKE-DEFAULT-KEY',
clickable: true,
editable: true,
icon: 'FAKE-ICON'
});
fixture.detectChanges();
const 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 defined', () => {
component.property = new CardViewTextItemModel({
label: 'Text label',
value: '',
@@ -168,8 +185,8 @@ describe('CardViewTextItemComponent', () => {
});
fixture.detectChanges();
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
expect(value).not.toBeNull();
let value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-${component.property.icon}"]`));
expect(value).toBeNull();
expect(value.nativeElement.innerText.trim()).toBe('FAKE-ICON');
});
@@ -307,6 +324,28 @@ describe('CardViewTextItemComponent', () => {
});
}));
it('should render the default as value if the value is empty, clickable is false and displayEmpty is true', (done) => {
let functionTestClick = () => {
done();
};
component.property = new CardViewTextItemModel({
label: 'Text label',
value: '',
key: 'textkey',
default: 'FAKE-DEFAULT-KEY',
clickable: true,
clickCallBack: () => {
functionTestClick();
}
});
component.displayEmpty = true;
fixture.detectChanges();
const value = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-value-${component.property.key}"]`));
value.nativeElement.click();
});
it('should trigger an update event on the CardViewUpdateService [integration]', (done) => {
component.inEdit = false;
component.property.isValid = () => true;

View File

@@ -57,7 +57,7 @@ export class CardViewTextItemComponent implements OnChanges {
}
isClickable(): boolean {
return this.property.clickable;
return !!this.property.clickable;
}
hasIcon(): boolean {
@@ -97,6 +97,10 @@ export class CardViewTextItemComponent implements OnChanges {
}
clicked(): void {
this.cardViewUpdateService.clicked(this.property);
if (typeof this.property.clickCallBack === 'function') {
this.property.clickCallBack();
} else {
this.cardViewUpdateService.clicked(this.property);
}
}
}