From 757128186c5e8a6142fddaa36bd3beda3eaeab43 Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Tue, 3 Oct 2017 15:47:13 +0100 Subject: [PATCH] [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 --- .../components/task-header.component.spec.ts | 17 +++++++++++++++++ .../src/components/task-header.component.ts | 13 +++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.spec.ts index bf6008a30d..9c852c7656 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.spec.ts @@ -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(); diff --git a/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.ts index d7b0ce606a..c1c2c67425 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/task-header.component.ts @@ -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 */