mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-5529] Include sorting params in the PeopleContentQueryRequestModel (#7182)
* [AAE-5529] Include sorting params in the PeopleContentQueryRequestModel * * Added unit tests to the recent changes on people content service * * Fixed comment
This commit is contained in:
@@ -32,9 +32,15 @@ export interface PeopleContentQueryResponse {
|
||||
entries: EcmUserModel[];
|
||||
}
|
||||
|
||||
export interface PeopleContentSortingModel {
|
||||
orderBy: string;
|
||||
direction: string;
|
||||
}
|
||||
|
||||
export interface PeopleContentQueryRequestModel {
|
||||
skipCount: number;
|
||||
maxItems: number;
|
||||
skipCount?: number;
|
||||
maxItems?: number;
|
||||
sorting?: PeopleContentSortingModel;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
@@ -46,6 +52,8 @@ export class PeopleContentService {
|
||||
|
||||
private _peopleApi: PeopleApi;
|
||||
|
||||
defaultSorting = ['firstName ASC'];
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private logService: LogService) {}
|
||||
|
||||
get peopleApi() {
|
||||
@@ -79,7 +87,13 @@ export class PeopleContentService {
|
||||
* @returns Response containing pagination and list of entries
|
||||
*/
|
||||
listPeople(requestQuery?: PeopleContentQueryRequestModel): Observable<PeopleContentQueryResponse> {
|
||||
const promise = this.peopleApi.listPeople(requestQuery);
|
||||
const orderBy = this.buildOrderArray(requestQuery?.sorting.orderBy, requestQuery?.sorting.direction);
|
||||
const requestQueryParams = {
|
||||
skipCount: requestQuery?.skipCount,
|
||||
maxItems: requestQuery?.maxItems,
|
||||
orderBy
|
||||
};
|
||||
const promise = this.peopleApi.listPeople(requestQueryParams);
|
||||
return from(promise).pipe(
|
||||
map(response => {
|
||||
return {
|
||||
@@ -113,6 +127,10 @@ export class PeopleContentService {
|
||||
return this.hasContentAdminRole;
|
||||
}
|
||||
|
||||
private buildOrderArray(key: string, direction: string): string[] {
|
||||
return key && direction ? [ `${key} ${direction.toUpperCase()}` ] : this.defaultSorting ;
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return throwError(error || 'Server error');
|
||||
|
Reference in New Issue
Block a user