mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[AAE-11992] pass only the processInstanceId as Input instead of the entire taskFilter object (#8140)
This commit is contained in:
parent
9d143cf945
commit
34e5508076
@ -67,6 +67,10 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
|||||||
@Input()
|
@Input()
|
||||||
id: string;
|
id: string;
|
||||||
|
|
||||||
|
/** processInstanceId of the task filter. */
|
||||||
|
@Input()
|
||||||
|
processInstanceId: string;
|
||||||
|
|
||||||
/** Toggles the title. */
|
/** Toggles the title. */
|
||||||
@Input()
|
@Input()
|
||||||
showTitle = true;
|
showTitle = true;
|
||||||
@ -147,12 +151,8 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
const { id, taskFilter } = changes;
|
const { id } = changes;
|
||||||
if(taskFilter && taskFilter.currentValue?.processInstanceId !== taskFilter.previousValue?.processInstanceId){
|
if (id && id.currentValue !== id.previousValue) {
|
||||||
this.taskFilterProperties = this.createAndFilterProperties();
|
|
||||||
this.taskFilterActions = this.createAndFilterActions();
|
|
||||||
this.buildForm(this.taskFilterProperties);
|
|
||||||
} else if (id && id.currentValue !== id.previousValue) {
|
|
||||||
this.retrieveTaskFilterAndBuildForm();
|
this.retrieveTaskFilterAndBuildForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,8 @@ import {
|
|||||||
mockDefaultTaskFilter,
|
mockDefaultTaskFilter,
|
||||||
mockDueDateFilter,
|
mockDueDateFilter,
|
||||||
mockTaskFilterIdChange,
|
mockTaskFilterIdChange,
|
||||||
mockTaskFilterProcessInstanceIdChange,
|
mockTaskFilterResponse,
|
||||||
mockTaskFilterProcessInstanceIdChangeToNull,
|
mockTaskFilterResponseWithProcessInstanceIdNull
|
||||||
mockTaskFilterProcessInstanceIdNotChanged,
|
|
||||||
mockTaskFilterWithProcessInstanceId2,
|
|
||||||
mockTaskFilterWithProcessInstanceIdNull
|
|
||||||
} from '../../mock/edit-task-filter-cloud.mock';
|
} from '../../mock/edit-task-filter-cloud.mock';
|
||||||
import { mockFoodUsers } from '../../../../people/mock/people-cloud.mock';
|
import { mockFoodUsers } from '../../../../people/mock/people-cloud.mock';
|
||||||
import { mockFoodGroups } from '../../../../group/mock/group-cloud.mock';
|
import { mockFoodGroups } from '../../../../group/mock/group-cloud.mock';
|
||||||
@ -135,48 +132,67 @@ describe('EditTaskFilterCloudComponent', () => {
|
|||||||
return fixture.debugElement.query(By.css(cssSelector.processInstanceIdInput)).nativeElement;
|
return fixture.debugElement.query(By.css(cssSelector.processInstanceIdInput)).nativeElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should set processInstanceId filter when processInstanceId changes', () => {
|
it('should set processInstanceId filter when id changes', async () => {
|
||||||
component.taskFilter = mockTaskFilterWithProcessInstanceId2;
|
getTaskFilterSpy.and.returnValue(of(mockTaskFilterResponse));
|
||||||
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
component.processInstanceId = 'fakeProcessInstanceId';
|
||||||
fixture.detectChanges();
|
|
||||||
component.ngOnChanges({ taskFilter: mockTaskFilterProcessInstanceIdChange});
|
|
||||||
fixture.detectChanges();
|
|
||||||
expandFilterPanel();
|
|
||||||
expect(getTaskFilterSpy).not.toHaveBeenCalled();
|
|
||||||
expect(getProcessInstanceIdInputElement().value).toEqual('fakeProcessInstance-2');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should processInstanceId filter be empty string if taskFilter processInstanceId change to null', () => {
|
|
||||||
component.taskFilter = mockTaskFilterWithProcessInstanceIdNull;
|
|
||||||
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
|
||||||
fixture.detectChanges();
|
|
||||||
component.ngOnChanges({ taskFilter: mockTaskFilterProcessInstanceIdChangeToNull});
|
|
||||||
fixture.detectChanges();
|
|
||||||
expandFilterPanel();
|
|
||||||
expect(getTaskFilterSpy).not.toHaveBeenCalled();
|
|
||||||
expect(getProcessInstanceIdInputElement().value).toEqual('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should processInstanceId filter be empty string if id of the task filter is changed', () => {
|
|
||||||
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.ngOnChanges({ id: mockTaskFilterIdChange });
|
component.ngOnChanges({ id: mockTaskFilterIdChange });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
expandFilterPanel();
|
||||||
|
expect(getProcessInstanceIdInputElement().value).toEqual('fakeProcessInstanceId');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should processInstanceId filter be empty string if processInstanceId is null', async () => {
|
||||||
|
getTaskFilterSpy.and.returnValue(of(mockTaskFilterResponseWithProcessInstanceIdNull));
|
||||||
|
component.processInstanceId = null;
|
||||||
|
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges({ id: mockTaskFilterIdChange });
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
expandFilterPanel();
|
expandFilterPanel();
|
||||||
expect(getTaskFilterSpy).toHaveBeenCalled();
|
|
||||||
expect(getProcessInstanceIdInputElement().value).toEqual('');
|
expect(getProcessInstanceIdInputElement().value).toEqual('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should processInstanceId filter be empty string if id of the task filter is changed', () => {
|
it('should processInstanceId filter be empty string if processInstanceId is undefined', async () => {
|
||||||
|
getTaskFilterSpy.and.returnValue(of(mockTaskFilterResponseWithProcessInstanceIdNull));
|
||||||
|
component.processInstanceId = undefined;
|
||||||
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.ngOnChanges({ id: mockTaskFilterIdChange, taskFilter: mockTaskFilterProcessInstanceIdNotChanged });
|
component.ngOnChanges({ id: mockTaskFilterIdChange });
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
expandFilterPanel();
|
expandFilterPanel();
|
||||||
expect(getTaskFilterSpy).toHaveBeenCalled();
|
|
||||||
expect(getProcessInstanceIdInputElement().value).toEqual('');
|
expect(getProcessInstanceIdInputElement().value).toEqual('');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should processInstanceId filter be set with the processInstanceId from response if processInstanceId input is null', async () => {
|
||||||
|
getTaskFilterSpy.and.returnValue(of(mockTaskFilterResponse));
|
||||||
|
component.processInstanceId = null;
|
||||||
|
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges({ id: mockTaskFilterIdChange });
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
expandFilterPanel();
|
||||||
|
expect(getProcessInstanceIdInputElement().value).toEqual('fakeProcessInstanceIdFromResponse');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should processInstanceId filter be set with the processInstanceId from response if processInstanceId input is undefined', async () => {
|
||||||
|
getTaskFilterSpy.and.returnValue(of(mockTaskFilterResponse));
|
||||||
|
component.processInstanceId = undefined;
|
||||||
|
component.filterProperties = [ 'appName', 'processInstanceId', 'sort', 'order'];
|
||||||
|
fixture.detectChanges();
|
||||||
|
component.ngOnChanges({ id: mockTaskFilterIdChange });
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
expandFilterPanel();
|
||||||
|
expect(getProcessInstanceIdInputElement().value).toEqual('fakeProcessInstanceIdFromResponse');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fetch process definitions when processDefinitionName filter property is set', async () => {
|
it('should fetch process definitions when processDefinitionName filter property is set', async () => {
|
||||||
|
@ -192,7 +192,7 @@ export class EditTaskFilterCloudComponent extends BaseEditTaskFilterCloudCompone
|
|||||||
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.PROCESS_INSTANCE_ID',
|
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.PROCESS_INSTANCE_ID',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
key: 'processInstanceId',
|
key: 'processInstanceId',
|
||||||
value: this.taskFilter.processInstanceId || ''
|
value: this.processInstanceId || this.taskFilter.processInstanceId || ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.PROCESS_DEF_ID',
|
label: 'ADF_CLOUD_EDIT_TASK_FILTER.LABEL.PROCESS_DEF_ID',
|
||||||
|
@ -29,27 +29,29 @@ export const mockAlfrescoApi: any = {
|
|||||||
|
|
||||||
export const mockTaskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
export const mockTaskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
|
||||||
|
|
||||||
export const mockTaskFilterWithProcessInstanceId1: any = { id: 'fakeId-1', processInstanceId: 'fakeProcessInstance-1', appName: 'fakeAppName', sort: 'startDate', order: 'DESC' };
|
export const mockTaskFilterResponse = {
|
||||||
export const mockTaskFilterWithProcessInstanceId2: any = { ...mockTaskFilterWithProcessInstanceId1, processInstanceId: 'fakeProcessInstance-2' };
|
name: 'FakeInvolvedTasks',
|
||||||
export const mockTaskFilterWithProcessInstanceIdNull: any = { ...mockTaskFilterWithProcessInstanceId1, processInstanceId: null };
|
icon: 'adjust',
|
||||||
|
id: 'mock-task-filter-id',
|
||||||
|
appName: 'mock-app-name',
|
||||||
|
processDefinitionId: 'process-def-id',
|
||||||
|
assignee: 'fake-involved',
|
||||||
|
order: 'ASC',
|
||||||
|
sort: 'id',
|
||||||
|
processInstanceId: 'fakeProcessInstanceIdFromResponse'
|
||||||
|
};
|
||||||
|
|
||||||
export const mockTaskFilterProcessInstanceIdChange = new SimpleChange(
|
export const mockTaskFilterResponseWithProcessInstanceIdNull = {
|
||||||
mockTaskFilterWithProcessInstanceId1,
|
name: 'FakeInvolvedTasks',
|
||||||
mockTaskFilterWithProcessInstanceId2,
|
icon: 'adjust',
|
||||||
true
|
id: 'mock-task-filter-id',
|
||||||
);
|
appName: 'mock-app-name',
|
||||||
|
processDefinitionId: 'process-def-id',
|
||||||
export const mockTaskFilterProcessInstanceIdNotChanged = new SimpleChange(
|
assignee: 'fake-involved',
|
||||||
mockTaskFilterWithProcessInstanceId1,
|
order: 'ASC',
|
||||||
mockTaskFilterWithProcessInstanceId1,
|
sort: 'id',
|
||||||
false
|
processInstanceId: null
|
||||||
);
|
};
|
||||||
|
|
||||||
export const mockTaskFilterProcessInstanceIdChangeToNull = new SimpleChange(
|
|
||||||
mockTaskFilterWithProcessInstanceId1,
|
|
||||||
mockTaskFilterWithProcessInstanceIdNull,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
export const mockDefaultTaskFilter = {
|
export const mockDefaultTaskFilter = {
|
||||||
name: 'ADF_CLOUD_TASK_FILTERS.MY_TASKS',
|
name: 'ADF_CLOUD_TASK_FILTERS.MY_TASKS',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user