[REPO-5552] more filtering capabilities for aspect/type api (#6713)

* [REPO-5552] more filtering capabilities for aspect/type api

* * fix BC
This commit is contained in:
dhrn
2021-02-26 03:20:14 +05:30
committed by GitHub
parent 42a5102e66
commit c932cb0964
4 changed files with 36 additions and 21 deletions

View File

@@ -45,27 +45,35 @@ export class AspectListService {
}
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([]);
})
);
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<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[] {

View File

@@ -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) => <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 });
}));
}

View File

@@ -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();
});
});

View File

@@ -33,7 +33,11 @@ export class ContentTypeService {
}
getContentTypeChildren(nodeType: string): Observable<TypeEntry[]> {
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)
);