[ADF-1632] Task Header - The default parent name value should be None (#2409)

* The default parent name should be None

* Fix trim

* add js doc
This commit is contained in:
Maurizio Vitale 2017-10-03 15:47:13 +01:00 committed by Popovics András
parent 93a87af4a5
commit 757128186c
2 changed files with 28 additions and 2 deletions

View File

@ -198,6 +198,23 @@ describe('TaskHeaderComponent', () => {
expect(valueEl.nativeElement.innerText).toBe('test form');
});
it('should display the default parent value if is undefined', () => {
component.taskDetails.processInstanceId = null;
component.ngOnChanges({});
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-parentName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toEqual('None');
});
it('should display the Parent name value', () => {
component.taskDetails.processInstanceId = '1';
component.taskDetails.processDefinitionName = 'Parent Name';
component.ngOnChanges({});
fixture.detectChanges();
let valueEl = fixture.debugElement.query(By.css('[data-automation-id="header-parentName"] .adf-property-value'));
expect(valueEl.nativeElement.innerText.trim()).toEqual('Parent Name');
});
it('should not display form name if no form name provided', () => {
component.ngOnChanges({});
fixture.detectChanges();

View File

@ -55,13 +55,13 @@ export class TaskHeaderComponent implements OnChanges {
*/
refreshData() {
if (this.taskDetails) {
let valueMap = new Map([[this.taskDetails.processInstanceId, this.taskDetails.processDefinitionName]]);
const parentInfoMap = this.getParentInfo();
this.properties = [
new CardViewTextItemModel({ label: 'Assignee', value: this.taskDetails.getFullName(), key: 'assignee', default: 'No assignee', clickable: !this.isCompleted() } ),
new CardViewTextItemModel({ label: 'Status', value: this.getTaskStatus(), key: 'status' }),
new CardViewDateItemModel({ label: 'Due Date', value: this.taskDetails.dueDate, key: 'dueDate', default: 'No date', editable: true }),
new CardViewTextItemModel({ label: 'Category', value: this.taskDetails.category, key: 'category', default: 'No category' }),
new CardViewMapItemModel({ label: 'Parent name', value: valueMap, key: 'parentName', default: 'No parent name', clickable: true }),
new CardViewMapItemModel({ label: 'Parent name', value: parentInfoMap, key: 'parentName', default: 'None', clickable: true }),
new CardViewTextItemModel({ label: 'Created By', value: this.taskDetails.getFullName(), key: 'created-by', default: 'No assignee' }),
new CardViewDateItemModel({ label: 'Created', value: this.taskDetails.created, key: 'created' }),
new CardViewTextItemModel({ label: 'Id', value: this.taskDetails.id, key: 'id' }),
@ -78,6 +78,15 @@ export class TaskHeaderComponent implements OnChanges {
}
}
/**
* Return the process parent information
*/
getParentInfo() {
if (this.taskDetails.processInstanceId && this.taskDetails.processDefinitionName) {
return new Map([[this.taskDetails.processInstanceId, this.taskDetails.processDefinitionName]]);
}
}
/**
* Does the task have an assignee
*/