mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
Do not reload the tasks when the taskId and currentTask are the same (#1856)
This commit is contained in:
committed by
Eugenio Romano
parent
c07d12261f
commit
5ba1202292
+48
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user