From c932cb096408fcc341668f4f8c4a5392ea9dab3d Mon Sep 17 00:00:00 2001 From: dhrn <14145706+dhrn@users.noreply.github.com> Date: Fri, 26 Feb 2021 03:20:14 +0530 Subject: [PATCH] [REPO-5552] more filtering capabilities for aspect/type api (#6713) * [REPO-5552] more filtering capabilities for aspect/type api * * fix BC --- .../lib/aspect-list/aspect-list.service.ts | 42 +++++++++++-------- .../services/content-type-property.service.ts | 4 +- .../content-type/content-type.service.spec.ts | 5 ++- .../lib/content-type/content-type.service.ts | 6 ++- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/lib/content-services/src/lib/aspect-list/aspect-list.service.ts b/lib/content-services/src/lib/aspect-list/aspect-list.service.ts index cf9dcb9f15..adc3722e57 100644 --- a/lib/content-services/src/lib/aspect-list/aspect-list.service.ts +++ b/lib/content-services/src/lib/aspect-list/aspect-list.service.ts @@ -45,27 +45,35 @@ export class AspectListService { } getStandardAspects(whiteList: string[]): Observable { - const where = `(modelIds in ('cm:contentmodel', 'emailserver:emailserverModel', 'smf:smartFolder', 'app:applicationmodel' ))`; - return from(this.alfrescoApiService.aspectsApi.listAspects({where})) - .pipe( - map((result: AspectPaging) => this.filterAspectByConfig(whiteList, result?.list?.entries)), - catchError((error) => { - this.logService.error(error); - return of([]); - }) - ); + const where = `(modelId in ('cm:contentmodel', 'emailserver:emailserverModel', 'smf:smartFolder', 'app:applicationmodel' ))`; + const opts: any = { + where, + include: ['properties'] + }; + return from(this.alfrescoApiService.aspectsApi.listAspects(opts)) + .pipe( + map((result: AspectPaging) => this.filterAspectByConfig(whiteList, result?.list?.entries)), + catchError((error) => { + this.logService.error(error); + return of([]); + }) + ); } getCustomAspects(): Observable { const where = `(not namespaceUri matches('http://www.alfresco.*'))`; - return from(this.alfrescoApiService.aspectsApi.listAspects({where})) - .pipe( - map((result: AspectPaging) => result?.list?.entries), - catchError((error) => { - this.logService.error(error); - return of([]); - }) - ); + const opts: any = { + where, + include: ['properties'] + }; + return from(this.alfrescoApiService.aspectsApi.listAspects(opts)) + .pipe( + map((result: AspectPaging) => result?.list?.entries), + catchError((error) => { + this.logService.error(error); + return of([]); + }) + ); } private filterAspectByConfig(visibleAspectList: string[], aspectEntries: AspectEntry[]): AspectEntry[] { diff --git a/lib/content-services/src/lib/content-metadata/services/content-type-property.service.ts b/lib/content-services/src/lib/content-metadata/services/content-type-property.service.ts index af34ec994b..c273d89bdf 100644 --- a/lib/content-services/src/lib/content-metadata/services/content-type-property.service.ts +++ b/lib/content-services/src/lib/content-metadata/services/content-type-property.service.ts @@ -38,7 +38,7 @@ export class ContentTypePropertiesService { pipe( map((contentType) => { const contentTypesOptions$ = this.getContentTypesAsSelectOption(contentType); - const contentTypeCard = this.buildContentTypeSelectCardModel(contentType.entry.id, contentTypesOptions$); + const contentTypeCard = this.buildContentTypeSelectCardModel(contentType.entry.id, contentTypesOptions$); return [contentTypeCard]; })); } @@ -61,7 +61,7 @@ export class ContentTypePropertiesService { distinctUntilChanged(), map(([contentTypesEntries, currentContentType]) => { const updatedTypes = this.appendCurrentType(currentContentType, contentTypesEntries); - return updatedTypes.map((contentType) => > { key: contentType.entry.id, label: contentType.entry.title ?? contentType.entry.id}); + return updatedTypes.map((contentType) => > { key: contentType.entry.id, label: contentType.entry.title ?? contentType.entry.id }); })); } diff --git a/lib/content-services/src/lib/content-type/content-type.service.spec.ts b/lib/content-services/src/lib/content-type/content-type.service.spec.ts index b7a1474a85..dec00be75d 100644 --- a/lib/content-services/src/lib/content-type/content-type.service.spec.ts +++ b/lib/content-services/src/lib/content-type/content-type.service.spec.ts @@ -58,7 +58,10 @@ describe('ContentTypeService', () => { expect(results).not.toBeNull(); expect(results.length).toBe(1); expect(results[0].entry.id).toBe('fake-type-id'); - expect(mockTypesApi.listTypes).toHaveBeenCalledWith({ where: '(parentIds in (\'whatever-whenever\') and not namespaceUri matches(\'http://www.alfresco.org/model.*\'))' }); + expect(mockTypesApi.listTypes).toHaveBeenCalledWith({ + where: '(parentId in (\'whatever-whenever\') and not namespaceUri matches(\'http://www.alfresco.*\'))', + include: [ 'properties'] + }); done(); }); }); diff --git a/lib/content-services/src/lib/content-type/content-type.service.ts b/lib/content-services/src/lib/content-type/content-type.service.ts index ebc20336d8..2446e72857 100644 --- a/lib/content-services/src/lib/content-type/content-type.service.ts +++ b/lib/content-services/src/lib/content-type/content-type.service.ts @@ -33,7 +33,11 @@ export class ContentTypeService { } getContentTypeChildren(nodeType: string): Observable { - const opts = {where : `(parentIds in ('${nodeType}') and not namespaceUri matches('http://www.alfresco.org/model.*'))`}; + const where = `(parentId in ('${nodeType}') and not namespaceUri matches('http://www.alfresco.*'))`; + const opts: any = { + where, + include: ['properties'] + }; return from(this.alfrescoApiService.typesApi.listTypes(opts)).pipe( map((result: TypePaging) => result.list.entries) );