mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-02 17:53:30 +00:00
AAE-46476 Fix sorting functionality of task list retrieval from runtime bundle (#11921)
This commit is contained in:
@@ -84,18 +84,6 @@ export class BaseCloudService {
|
||||
);
|
||||
}
|
||||
|
||||
protected getWithBody<T, R>(url: string, data?: T, queryParams?: any): Observable<R> {
|
||||
return from(
|
||||
this.callApi<R>(url, {
|
||||
...this.defaultParams,
|
||||
path: url,
|
||||
httpMethod: 'GET',
|
||||
bodyParam: data,
|
||||
queryParams
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
protected callApi<T>(url: string, params: RequestOptions): Promise<T> {
|
||||
return this.adfHttpClient.request(url, params);
|
||||
}
|
||||
|
||||
+38
@@ -189,6 +189,44 @@ describe('TaskListCloudService', () => {
|
||||
expect(res.maxItems).toBe(25);
|
||||
});
|
||||
|
||||
it('should include sort parameter when sorting.orderBy is set', async () => {
|
||||
const taskRequest = {
|
||||
appName: 'fakeName',
|
||||
pagination: { skipCount: 0, maxItems: 20 },
|
||||
sorting: { orderBy: 'NAME', direction: 'DESC', isFieldProcessVariable: false }
|
||||
} as TaskListRequestModel;
|
||||
requestSpy.and.callFake(returnCallQueryParameters);
|
||||
|
||||
const res = await firstValueFrom(service.fetchTaskList_UsingRuntimeBundleService(taskRequest));
|
||||
|
||||
expect(res.sort).toBe('NAME,DESC');
|
||||
});
|
||||
|
||||
it('should not include sort parameter when sorting is not set', async () => {
|
||||
const taskRequest = {
|
||||
appName: 'fakeName',
|
||||
pagination: { skipCount: 0, maxItems: 20 }
|
||||
} as TaskListRequestModel;
|
||||
requestSpy.and.callFake(returnCallQueryParameters);
|
||||
|
||||
const res = await firstValueFrom(service.fetchTaskList_UsingRuntimeBundleService(taskRequest));
|
||||
|
||||
expect(res.sort).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should not include sort parameter when sorting.orderBy is empty', async () => {
|
||||
const taskRequest = {
|
||||
appName: 'fakeName',
|
||||
pagination: { skipCount: 0, maxItems: 20 },
|
||||
sorting: { orderBy: '', direction: 'DESC', isFieldProcessVariable: false }
|
||||
} as TaskListRequestModel;
|
||||
requestSpy.and.callFake(returnCallQueryParameters);
|
||||
|
||||
const res = await firstValueFrom(service.fetchTaskList_UsingRuntimeBundleService(taskRequest));
|
||||
|
||||
expect(res.sort).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should return an error when app name is not specified', async () => {
|
||||
const taskRequest = { appName: null } as TaskListRequestModel;
|
||||
requestSpy.and.callFake(returnCallUrl);
|
||||
|
||||
+5
-3
@@ -97,14 +97,16 @@ export class TaskListCloudService extends BaseCloudService implements TaskListCl
|
||||
|
||||
const url = `${this.getBasePath(requestNode.appName)}/rb/v1/tasks`;
|
||||
|
||||
const queryParams = {
|
||||
const queryParams: { maxItems: number; skipCount: number; sort?: string } = {
|
||||
maxItems: requestNode.pagination?.maxItems || 25,
|
||||
skipCount: requestNode.pagination?.skipCount || 0
|
||||
};
|
||||
|
||||
const queryData = this.buildQueryData(requestNode);
|
||||
if (requestNode.sorting?.orderBy) {
|
||||
queryParams.sort = `${requestNode.sorting.orderBy},${requestNode.sorting.direction}`;
|
||||
}
|
||||
|
||||
return this.getWithBody<any, TaskCloudNodePaging>(url, queryData, queryParams).pipe(
|
||||
return this.get<TaskCloudNodePaging>(url, queryParams).pipe(
|
||||
map((response) => {
|
||||
const entries = response.list?.entries;
|
||||
if (entries) {
|
||||
|
||||
Reference in New Issue
Block a user