From 5ca66bb75f9e2c0673f1508768df2181e11d77f4 Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Thu, 2 Nov 2017 15:30:23 +0000 Subject: [PATCH] Select the currentTask (#2598) --- .../components/task-list.component.spec.ts | 20 +++++++++++++++++++ .../src/components/task-list.component.ts | 1 + 2 files changed, 21 insertions(+) diff --git a/ng2-components/ng2-activiti-tasklist/src/components/task-list.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/task-list.component.spec.ts index 4112c1c6b2..ca957463ad 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/task-list.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/task-list.component.spec.ts @@ -278,6 +278,26 @@ describe('TaskListComponent', () => { expect(component.getCurrentId()).toBeNull(); }); + it('should return selected true for the selected task', () => { + component.data = new ObjectDataTableAdapter( + [ + {id: '999', name: 'Fake-name'}, + {id: '888', name: 'Fake-name-888'} + ], + [ + {type: 'text', key: 'id', title: 'Id'}, + {type: 'text', key: 'name', title: 'Name'} + ] + ); + component.selectTask('888'); + const dataRow = component.data.getRows(); + expect(dataRow).toBeDefined(); + expect(dataRow[0].getValue('id')).toEqual('999'); + expect(dataRow[0].isSelected).toEqual(false); + expect(dataRow[1].getValue('id')).toEqual('888'); + expect(dataRow[1].isSelected).toEqual(true); + }); + it('should throw an exception when the response is wrong', (done) => { let state = new SimpleChange(null, 'open', true); let assignment = new SimpleChange(null, 'fake-assignee', true); diff --git a/ng2-components/ng2-activiti-tasklist/src/components/task-list.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/task-list.component.ts index 081eb941a0..412c9e0465 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/task-list.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/task-list.component.ts @@ -234,6 +234,7 @@ export class TaskListComponent implements OnChanges, OnInit, AfterContentInit { if (rows.length > 0) { let dataRow = rows.find(row => row.getValue('id') === taskIdToSelect) || rows[0]; this.data.selectedRow = dataRow; + dataRow.isSelected = true; this.currentInstanceId = dataRow.getValue('id'); } } else {