mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
[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:
parent
38f2973863
commit
313d7f30cf
@ -55,6 +55,7 @@ export interface CardViewItem {
|
|||||||
type: string;
|
type: string;
|
||||||
displayValue: string;
|
displayValue: string;
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
|
icon?: string;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -77,7 +78,8 @@ Each of them extends the abstract CardViewBaseItemModel class to add some custom
|
|||||||
value: 'Spock',
|
value: 'Spock',
|
||||||
key: 'name',
|
key: 'name',
|
||||||
default: 'default bar' ,
|
default: 'default bar' ,
|
||||||
multiline: false
|
multiline: false,
|
||||||
|
icon: 'icon';
|
||||||
}),
|
}),
|
||||||
new CardViewMapItemModel({
|
new CardViewMapItemModel({
|
||||||
label: 'My map',
|
label: 'My map',
|
||||||
@ -141,6 +143,7 @@ const textItemProperty = new CardViewTextItemModel(options);
|
|||||||
| displayValue\* | string | --- | The value to render |
|
| displayValue\* | string | --- | The value to render |
|
||||||
| editable | boolean | false | Whether the property editable or not |
|
| editable | boolean | false | Whether the property editable or not |
|
||||||
| clickable | boolean | false | Whether the property clickable or not |
|
| clickable | boolean | false | Whether the property clickable or not |
|
||||||
|
| icon | string | The material icon to show against the clickable property |
|
||||||
| multiline | string | false | Single or multiline text |
|
| multiline | string | false | Single or multiline text |
|
||||||
| pipes | CardViewTextItemPipeProperty\[] | \[] | Pipes to be applied on the displayValue |
|
| pipes | CardViewTextItemPipeProperty\[] | \[] | Pipes to be applied on the displayValue |
|
||||||
|
|
||||||
|
@ -5,9 +5,12 @@
|
|||||||
<span *ngIf="showProperty()">{{ property.displayValue }}</span>
|
<span *ngIf="showProperty()">{{ property.displayValue }}</span>
|
||||||
</span>
|
</span>
|
||||||
<ng-template #elseBlock>
|
<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 *ngIf="showProperty(); else elseEmptyValueBlock">{{ property.displayValue }}</span>
|
||||||
</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>
|
</ng-template>
|
||||||
</span>
|
</span>
|
||||||
<span *ngIf="isEditable()">
|
<span *ngIf="isEditable()">
|
||||||
|
@ -24,6 +24,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-textitem-clickable {
|
||||||
|
&:hover mat-icon {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&-textitem-clickable-value {
|
&-textitem-clickable-value {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: mat-color($primary);
|
color: mat-color($primary);
|
||||||
|
@ -185,6 +185,51 @@ describe('CardViewTextItemComponent', () => {
|
|||||||
expect(value.nativeElement.innerText.trim()).toBe('FAKE-DEFAULT-KEY');
|
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', () => {
|
it('should render value when editable:true', () => {
|
||||||
component.editable = true;
|
component.editable = true;
|
||||||
component.property.editable = true;
|
component.property.editable = true;
|
||||||
|
@ -59,6 +59,10 @@ export class CardViewTextItemComponent implements OnChanges {
|
|||||||
return this.property.clickable;
|
return this.property.clickable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasIcon(): boolean {
|
||||||
|
return !!this.property.icon;
|
||||||
|
}
|
||||||
|
|
||||||
hasErrors(): number {
|
hasErrors(): number {
|
||||||
return this.errorMessages && this.errorMessages.length;
|
return this.errorMessages && this.errorMessages.length;
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,6 @@ export interface CardViewItemProperties {
|
|||||||
default?: any;
|
default?: any;
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
clickable?: boolean;
|
clickable?: boolean;
|
||||||
|
icon?: string;
|
||||||
validators?: CardViewItemValidator[];
|
validators?: CardViewItemValidator[];
|
||||||
}
|
}
|
||||||
|
@ -23,4 +23,5 @@ export interface CardViewItem {
|
|||||||
type: string;
|
type: string;
|
||||||
displayValue: any;
|
displayValue: any;
|
||||||
editable?: boolean;
|
editable?: boolean;
|
||||||
|
icon?: string;
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ export abstract class CardViewBaseItemModel {
|
|||||||
default: any;
|
default: any;
|
||||||
editable: boolean;
|
editable: boolean;
|
||||||
clickable: boolean;
|
clickable: boolean;
|
||||||
|
icon?: string;
|
||||||
validators?: CardViewItemValidator[];
|
validators?: CardViewItemValidator[];
|
||||||
|
|
||||||
constructor(obj: CardViewItemProperties) {
|
constructor(obj: CardViewItemProperties) {
|
||||||
@ -33,6 +34,7 @@ export abstract class CardViewBaseItemModel {
|
|||||||
this.default = obj.default;
|
this.default = obj.default;
|
||||||
this.editable = !!obj.editable;
|
this.editable = !!obj.editable;
|
||||||
this.clickable = !!obj.clickable;
|
this.clickable = !!obj.clickable;
|
||||||
|
this.icon = obj.icon || '';
|
||||||
this.validators = obj.validators || [];
|
this.validators = obj.validators || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,18 +90,32 @@ describe('TaskHeaderComponent', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .adf-property-value'));
|
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .adf-textitem-clickable-value'));
|
||||||
expect(formNameEl.nativeElement.innerText).toBe('Wilbur Adams');
|
expect(formNameEl.nativeElement.innerText).toBe('Wilbur Adams');
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should display clickable edit icon', async(() => {
|
||||||
|
component.refreshData();
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
fixture.whenStable().then(() => {
|
||||||
|
let formNameEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .adf-textitem-clickable-value'));
|
||||||
|
let iconE = fixture.debugElement.query(By.css(`[data-automation-id="card-textitem-edit-icon-create"]`));
|
||||||
|
expect(formNameEl).not.toBeNull();
|
||||||
|
expect(iconE).not.toBeNull();
|
||||||
|
expect(formNameEl.nativeElement.innerText).toBe('Wilbur Adams');
|
||||||
|
expect(iconE.nativeElement.innerText.trim()).toBe('create');
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
|
||||||
it('should display placeholder if no assignee', async(() => {
|
it('should display placeholder if no assignee', async(() => {
|
||||||
component.taskDetails.assignee = null;
|
component.taskDetails.assignee = null;
|
||||||
component.refreshData();
|
component.refreshData();
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .adf-property-value'));
|
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-assignee"] .adf-textitem-clickable-value'));
|
||||||
expect(valueEl.nativeElement.innerText).toBe('ADF_TASK_LIST.PROPERTIES.ASSIGNEE_DEFAULT');
|
expect(valueEl.nativeElement.innerText).toBe('ADF_TASK_LIST.PROPERTIES.ASSIGNEE_DEFAULT');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -79,7 +79,8 @@ export class TaskHeaderComponent implements OnChanges, OnInit {
|
|||||||
value: this.taskDetails.getFullName(),
|
value: this.taskDetails.getFullName(),
|
||||||
key: 'assignee',
|
key: 'assignee',
|
||||||
default: this.translationService.instant('ADF_TASK_LIST.PROPERTIES.ASSIGNEE_DEFAULT'),
|
default: this.translationService.instant('ADF_TASK_LIST.PROPERTIES.ASSIGNEE_DEFAULT'),
|
||||||
clickable: !this.isCompleted()
|
clickable: !this.isCompleted(),
|
||||||
|
icon: 'create'
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
new CardViewTextItemModel(
|
new CardViewTextItemModel(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user