From 189bc6513d2a9e8da6489f3a17e8aa3d26d1ed9f Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Fri, 3 Nov 2017 09:47:49 +0000 Subject: [PATCH] Fix select current process (#2601) --- .../components/process-list.component.spec.ts | 20 +++++++++++++++++++ .../src/components/process-list.component.ts | 1 + 2 files changed, 21 insertions(+) diff --git a/ng2-components/ng2-activiti-processlist/src/components/process-list.component.spec.ts b/ng2-components/ng2-activiti-processlist/src/components/process-list.component.spec.ts index 8bdd9ae340..eb7e3e72e3 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/process-list.component.spec.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/process-list.component.spec.ts @@ -199,6 +199,26 @@ describe('ProcessInstanceListComponent', () => { expect(component.getCurrentId()).toBeNull(); }); + it('should return selected true for the selected process', () => { + 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.selectFirst(); + const dataRow = component.data.getRows(); + expect(dataRow).toBeDefined(); + expect(dataRow[0].getValue('id')).toEqual('999'); + expect(dataRow[0].isSelected).toEqual(true); + expect(dataRow[1].getValue('id')).toEqual('888'); + expect(dataRow[1].isSelected).toEqual(false); + }); + it('should throw an exception when the response is wrong', fakeAsync(() => { let emitSpy: jasmine.Spy = spyOn(component.error, 'emit'); let fakeError = 'Fake server error'; diff --git a/ng2-components/ng2-activiti-processlist/src/components/process-list.component.ts b/ng2-components/ng2-activiti-processlist/src/components/process-list.component.ts index db076585bc..b20f43a52f 100644 --- a/ng2-components/ng2-activiti-processlist/src/components/process-list.component.ts +++ b/ng2-components/ng2-activiti-processlist/src/components/process-list.component.ts @@ -198,6 +198,7 @@ export class ProcessInstanceListComponent implements OnChanges, AfterContentInit selectFirst() { if (!this.isListEmpty()) { let row = this.data.getRows()[0]; + row.isSelected = true; this.data.selectedRow = row; this.currentInstanceId = row.getValue('id'); } else {