Skip to content

Commit

Permalink
[REPO-5552] more filtering capabilities for aspect/type api
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrn committed Feb 22, 2021
1 parent f6308a7 commit 01cc79d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
46 changes: 27 additions & 19 deletions lib/content-services/src/lib/aspect-list/aspect-list.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,43 @@ export class AspectListService {

getAspects(): Observable<AspectEntry[]> {
const visibleAspectList = this.getVisibleAspects();
const standardAspects$ = this.getStandardAspects(visibleAspectList);
const standardAspects$ = this.getStandardAspects(visibleAspectList, ['properties']);
const customAspects$ = this.getCustomAspects();
return zip(standardAspects$, customAspects$).pipe(
map(([standardAspectList, customAspectList]) => [...standardAspectList, ...customAspectList])
);
}

getStandardAspects(whiteList: string[]): Observable<AspectEntry[]> {
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([]);
})
);
getStandardAspects(whiteList: string[], includeFields: string[] = []): Observable<AspectEntry[]> {
const where = `(modelId in ('cm:contentmodel', 'emailserver:emailserverModel', 'smf:smartFolder', 'app:applicationmodel' ))`;
const opts: any = {
where,
include: includeFields
};
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<AspectEntry[]> {
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[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}));
}
Expand All @@ -56,12 +56,12 @@ export class ContentTypePropertiesService {
}

private getContentTypesAsSelectOption(currentType: TypeEntry): Observable<CardViewSelectItemOption<string>[]> {
const childrenTypes$ = this.contentTypeService.getContentTypeChildren(currentType.entry.id);
const childrenTypes$ = this.contentTypeService.getContentTypeChildren(currentType.entry.id, ['properties']);
return zip(childrenTypes$, of(currentType)).pipe(
distinctUntilChanged(),
map(([contentTypesEntries, currentContentType]) => {
const updatedTypes = this.appendCurrentType(currentContentType, contentTypesEntries);
return updatedTypes.map((contentType) => <CardViewSelectItemOption<string>> { key: contentType.entry.id, label: contentType.entry.title ?? contentType.entry.id});
return updatedTypes.map((contentType) => <CardViewSelectItemOption<string>> { key: contentType.entry.id, label: contentType.entry.title ?? contentType.entry.id });
}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export class ContentTypeService {
return from(this.alfrescoApiService.typesApi.getType(prefixedType));
}

getContentTypeChildren(nodeType: string): Observable<TypeEntry[]> {
const opts = {where : `(parentIds in ('${nodeType}') and not namespaceUri matches('http://www.alfresco.org/model.*'))`};
getContentTypeChildren(nodeType: string, includeFields: string[] = []): Observable<TypeEntry[]> {
const where = `(parentId in ('${nodeType}') and not namespaceUri matches('http://www.alfresco.org/model.*'))`;
const opts: any = {
where,
include: includeFields
};
return from(this.alfrescoApiService.typesApi.listTypes(opts)).pipe(
map((result: TypePaging) => result.list.entries)
);
Expand Down

0 comments on commit 01cc79d

Please sign in to comment.