Do not reload the tasks when the taskId and currentTask are the same (#1856)

This commit is contained in:
Maurizio Vitale
2017-05-25 15:12:48 +01:00
committed by Eugenio Romano
parent c07d12261f
commit 5ba1202292
2 changed files with 58 additions and 1 deletions
@@ -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({});
@@ -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}