mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-40544 Add ability to filter out subprocesses (#11445)
* AAE-40544 Add ability to filter out subprocesses * dont send the value if not false * units
This commit is contained in:
+2
@@ -47,6 +47,7 @@ export class ProcessFilterCloudModel {
|
||||
completedDateType: DateCloudFilterType | null;
|
||||
startedDateType: DateCloudFilterType | null;
|
||||
suspendedDateType: DateCloudFilterType | null;
|
||||
includeSubprocesses: boolean | null;
|
||||
completedDate: Date | null;
|
||||
environmentId: string | null;
|
||||
showCounter: boolean;
|
||||
@@ -112,6 +113,7 @@ export class ProcessFilterCloudModel {
|
||||
this.completedDate = obj.completedDate || null;
|
||||
this._suspendedFrom = obj._suspendedFrom || null;
|
||||
this._suspendedTo = obj._suspendedTo || null;
|
||||
this.includeSubprocesses = obj.includeSubprocesses || null;
|
||||
|
||||
this.initArrayProperties(obj);
|
||||
}
|
||||
|
||||
+27
@@ -677,6 +677,33 @@ describe('ProcessListCloudComponent', () => {
|
||||
expect(component.processListRequestNode.appVersion.length).toEqual(0);
|
||||
});
|
||||
|
||||
it('should set includeSubprocesses to true in request node when input is true', () => {
|
||||
spyOn(processListCloudService, 'fetchProcessList').and.returnValue(of(fakeProcessCloudList));
|
||||
component.includeSubprocesses = true;
|
||||
component.ngAfterContentInit();
|
||||
component.reload();
|
||||
|
||||
expect(component.processListRequestNode.includeSubprocesses).toBeTrue();
|
||||
});
|
||||
|
||||
it('should set includeSubprocesses to false in request node when input is false', () => {
|
||||
spyOn(processListCloudService, 'fetchProcessList').and.returnValue(of(fakeProcessCloudList));
|
||||
component.includeSubprocesses = false;
|
||||
component.ngAfterContentInit();
|
||||
component.reload();
|
||||
|
||||
expect(component.processListRequestNode.includeSubprocesses).toBeFalse();
|
||||
});
|
||||
|
||||
it('should omit includeSubprocesses in request node when input is null', () => {
|
||||
spyOn(processListCloudService, 'fetchProcessList').and.returnValue(of(fakeProcessCloudList));
|
||||
component.includeSubprocesses = null;
|
||||
component.ngAfterContentInit();
|
||||
component.reload();
|
||||
|
||||
expect(component.processListRequestNode.includeSubprocesses).toBeNull();
|
||||
});
|
||||
|
||||
it('should return the results if an application name is given', (done) => {
|
||||
spyOn(processListCloudService, 'fetchProcessList').and.returnValue(of(fakeProcessCloudList));
|
||||
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
|
||||
|
||||
+5
@@ -290,6 +290,10 @@ export class ProcessListCloudComponent
|
||||
@Input()
|
||||
processVariables: ProcessVariableFilterModel[];
|
||||
|
||||
/** Include subprocesses in the process list. */
|
||||
@Input()
|
||||
includeSubprocesses: boolean | null = null;
|
||||
|
||||
/** Emitted when a row in the process list is clicked. */
|
||||
@Output()
|
||||
rowClick: EventEmitter<string> = new EventEmitter<string>();
|
||||
@@ -606,6 +610,7 @@ export class ProcessListCloudComponent
|
||||
completedTo: this.completedTo,
|
||||
suspendedFrom: this.suspendedFrom,
|
||||
suspendedTo: this.suspendedTo,
|
||||
includeSubprocesses: this.includeSubprocesses,
|
||||
processVariableKeys: this.getVariableDefinitionsRequestModel(),
|
||||
processVariableFilters: this.processVariables
|
||||
};
|
||||
|
||||
+3
@@ -102,6 +102,7 @@ export class ProcessListRequestModel {
|
||||
completedTo?: string;
|
||||
suspendedFrom?: string;
|
||||
suspendedTo?: string;
|
||||
includeSubprocesses?: boolean;
|
||||
|
||||
processVariableFilters?: ProcessVariableFilterModel[];
|
||||
processVariableKeys?: string[];
|
||||
@@ -130,6 +131,8 @@ export class ProcessListRequestModel {
|
||||
this.completedTo = obj.completedTo;
|
||||
this.suspendedFrom = obj.suspendedFrom;
|
||||
this.suspendedTo = obj.suspendedTo;
|
||||
this.includeSubprocesses = obj.includeSubprocesses;
|
||||
|
||||
this.processVariableKeys = obj.processVariableKeys;
|
||||
this.processVariableFilters = obj.processVariableFilters;
|
||||
}
|
||||
|
||||
+40
@@ -174,6 +174,46 @@ describe('ProcessListCloudService', () => {
|
||||
|
||||
expect(error).toBe('Appname not configured');
|
||||
});
|
||||
|
||||
it('should include includeSubprocesses=true in body', async () => {
|
||||
const processRequest = {
|
||||
appName: 'fakeName',
|
||||
pagination: { skipCount: 0, maxItems: 20 },
|
||||
includeSubprocesses: true
|
||||
} as ProcessListRequestModel;
|
||||
requestSpy.and.callFake(returnCallBody);
|
||||
|
||||
const requestBodyParams = await firstValueFrom(service.fetchProcessList(processRequest));
|
||||
|
||||
expect(requestBodyParams).toEqual({ includeSubprocesses: true });
|
||||
});
|
||||
|
||||
it('should include includeSubprocesses=false in body', async () => {
|
||||
const processRequest = {
|
||||
appName: 'fakeName',
|
||||
pagination: { skipCount: 0, maxItems: 20 },
|
||||
includeSubprocesses: false
|
||||
} as ProcessListRequestModel;
|
||||
requestSpy.and.callFake(returnCallBody);
|
||||
|
||||
const requestBodyParams = await firstValueFrom(service.fetchProcessList(processRequest));
|
||||
|
||||
expect(requestBodyParams).toEqual({ includeSubprocesses: false });
|
||||
});
|
||||
|
||||
it('should omit includeSubprocesses when null', async () => {
|
||||
const processRequest = {
|
||||
appName: 'fakeName',
|
||||
pagination: { skipCount: 0, maxItems: 20 },
|
||||
includeSubprocesses: null
|
||||
} as unknown as ProcessListRequestModel;
|
||||
requestSpy.and.callFake(returnCallBody);
|
||||
|
||||
const requestBodyParams = await firstValueFrom(service.fetchProcessList(processRequest));
|
||||
|
||||
expect(requestBodyParams).toEqual({});
|
||||
expect(requestBodyParams.includeSubprocesses).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAdminProcessRequest', () => {
|
||||
|
||||
+3
-2
@@ -118,7 +118,8 @@ export class ProcessListCloudService extends BaseCloudService {
|
||||
suspendedFrom: requestNode.suspendedFrom,
|
||||
suspendedTo: requestNode.suspendedTo,
|
||||
processVariableKeys: requestNode.processVariableKeys,
|
||||
processVariableFilters: requestNode.processVariableFilters
|
||||
processVariableFilters: requestNode.processVariableFilters,
|
||||
includeSubprocesses: requestNode.includeSubprocesses
|
||||
};
|
||||
|
||||
if (requestNode.sorting) {
|
||||
@@ -147,7 +148,7 @@ export class ProcessListCloudService extends BaseCloudService {
|
||||
*/
|
||||
Object.keys(queryData).forEach((key) => {
|
||||
const value = queryData[key];
|
||||
const isValueEmpty = !value;
|
||||
const isValueEmpty = value === undefined || value === null || value === '';
|
||||
const isValueArrayWithEmptyValue = Array.isArray(value) && (value.length === 0 || value[0] === null);
|
||||
if (isValueEmpty || isValueArrayWithEmptyValue) {
|
||||
delete queryData[key];
|
||||
|
||||
Reference in New Issue
Block a user