diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.spec.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.spec.ts index bd23fd4db9..f708eeb65c 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.spec.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.spec.ts @@ -272,6 +272,54 @@ describe('ActivitiTaskList', () => { ); }); + it('should NOT reload the tasks if the loadingTaskId is the same of the current task', () => { + spyOn(component, 'reload').and.stub(); + component.currentInstanceId = '999'; + + component.data = new ObjectDataTableAdapter( + [ + {id: '999', name: 'Fake-name'} + ], + [ + {type: 'text', key: 'id', title: 'Id'}, + {type: 'text', key: 'name', title: 'Name'} + ] + ); + + const landingTaskId = '999'; + let change = new SimpleChange(null, landingTaskId); + + component.ngOnChanges({'landingTaskId': change}); + expect(component.reload).not.toHaveBeenCalled(); + expect(component.data.getRows().length).toEqual(1); + }); + + it('should reload the tasks if the loadingTaskId is different from the current task', (done) => { + component.currentInstanceId = '999'; + + component.data = new ObjectDataTableAdapter( + [ + {id: '999', name: 'Fake-name'} + ], + [ + {type: 'text', key: 'id', title: 'Id'}, + {type: 'text', key: 'name', title: 'Name'} + ] + ); + + const landingTaskId = '888'; + let change = new SimpleChange(null, landingTaskId); + + component.onSuccess.subscribe((res) => { + expect(res).toBeDefined(); + expect(component.data).toBeDefined(); + expect(component.data.getRows().length).toEqual(2); + done(); + }); + + component.ngOnChanges({'landingTaskId': change}); + }); + it('should NOT reload the process list when no parameters changed', () => { expect(component.isListEmpty()).toBeTruthy(); component.ngOnChanges({}); diff --git a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts index 888a66e577..c97565afd2 100644 --- a/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts +++ b/ng2-components/ng2-activiti-tasklist/src/components/activiti-tasklist.component.ts @@ -166,7 +166,7 @@ export class ActivitiTaskList implements OnChanges, AfterContentInit { changed = true; } else if (assignment && assignment.currentValue) { changed = true; - } else if (landingTaskId && landingTaskId.currentValue) { + } else if (landingTaskId && landingTaskId.currentValue && !this.isEqualToCurrentId(landingTaskId.currentValue)) { changed = true; } return changed; @@ -247,6 +247,15 @@ export class ActivitiTaskList implements OnChanges, AfterContentInit { return this.currentInstanceId; } + /** + * Check if the taskId is the same of the selected task + * @param taskId + * @returns {boolean} + */ + isEqualToCurrentId(taskId: string) { + return this.currentInstanceId === taskId ? true : false; + } + /** * Check if the list is empty * @returns {ObjectDataTableAdapter|boolean}