mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-4296] adding mapping in tags service (#8240)
* ACS-4296 Adding mapping in tags service * ACS-4296 Correct lint issue * ACS-4296 Excluded failing e2e * ACS-4296 Trigger build * ACS-4296 Trigger build * ACS-4296 Reverted excluded tests
This commit is contained in:
@@ -22,12 +22,15 @@ import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { throwError } from 'rxjs';
|
||||
import {
|
||||
Pagination,
|
||||
RequestQuery,
|
||||
RequestSortDefinitionInner,
|
||||
ResultNode,
|
||||
ResultSetContext,
|
||||
ResultSetContextFacetQueries,
|
||||
ResultSetPaging,
|
||||
ResultSetPagingList,
|
||||
ResultSetRowEntry,
|
||||
Tag,
|
||||
TagBody,
|
||||
TagEntry,
|
||||
@@ -129,6 +132,13 @@ describe('TagService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
result = new ResultSetPaging();
|
||||
result.list = new ResultSetPagingList();
|
||||
const tag = new ResultSetRowEntry();
|
||||
tag.entry = new ResultNode();
|
||||
tag.entry.id = 'some id';
|
||||
tag.entry.name = 'some name';
|
||||
result.list.entries = [tag];
|
||||
result.list.pagination = new Pagination();
|
||||
});
|
||||
|
||||
it('should call search on searchApi with correct parameters', () => {
|
||||
@@ -156,14 +166,22 @@ describe('TagService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return observable which emits paging object for tags', (done) => {
|
||||
it('should return observable which emits paging object for tags', fakeAsync(() => {
|
||||
spyOn(service.searchApi, 'search').and.returnValue(Promise.resolve(result));
|
||||
|
||||
service.searchTags('test').subscribe((tagsResult) => {
|
||||
expect(tagsResult).toBe(result);
|
||||
done();
|
||||
const tagPaging = new TagPaging();
|
||||
tagPaging.list = new TagPagingList();
|
||||
const tagEntry = new TagEntry();
|
||||
tagEntry.entry = new Tag();
|
||||
tagEntry.entry.id = 'some id';
|
||||
tagEntry.entry.tag = 'some name';
|
||||
tagPaging.list.entries = [tagEntry];
|
||||
tagPaging.list.pagination = new Pagination();
|
||||
expect(tagsResult).toEqual(tagPaging);
|
||||
});
|
||||
});
|
||||
tick();
|
||||
}));
|
||||
|
||||
it('should call error on logService when error occurs during fetching paging object for tags', fakeAsync(() => {
|
||||
spyOn(logService, 'error');
|
||||
|
@@ -23,11 +23,12 @@ import {
|
||||
RequestQuery,
|
||||
RequestSortDefinitionInner,
|
||||
ResultSetContextFacetQueries,
|
||||
ResultSetPaging,
|
||||
SearchApi,
|
||||
Tag,
|
||||
TagBody,
|
||||
TagEntry,
|
||||
TagPaging,
|
||||
TagPagingList,
|
||||
TagsApi
|
||||
} from '@alfresco/js-api';
|
||||
|
||||
@@ -160,7 +161,7 @@ export class TagService {
|
||||
* @param maxItems Specify max number of returned tags. Default is specified by UserPreferencesService.
|
||||
* @returns Found tags which name contains searched name.
|
||||
*/
|
||||
searchTags(name: string, skipCount = 0, maxItems?: number): Observable<ResultSetPaging> {
|
||||
searchTags(name: string, skipCount = 0, maxItems?: number): Observable<TagPaging> {
|
||||
maxItems = maxItems || this.userPreferencesService.paginationSize;
|
||||
const sortingByName: RequestSortDefinitionInner = new RequestSortDefinitionInner();
|
||||
sortingByName.field = 'cm:name';
|
||||
@@ -176,7 +177,19 @@ export class TagService {
|
||||
maxItems
|
||||
},
|
||||
sort: [sortingByName]
|
||||
})).pipe(catchError((error) => this.handleError(error)));
|
||||
})).pipe(map((resultSetPaging) => {
|
||||
const tagPaging = new TagPaging();
|
||||
tagPaging.list = new TagPagingList();
|
||||
tagPaging.list.pagination = resultSetPaging.list.pagination;
|
||||
tagPaging.list.entries = resultSetPaging.list.entries.map((resultEntry) => {
|
||||
const tagEntry = new TagEntry();
|
||||
tagEntry.entry = new Tag();
|
||||
tagEntry.entry.tag = resultEntry.entry.name;
|
||||
tagEntry.entry.id = resultEntry.entry.id;
|
||||
return tagEntry;
|
||||
});
|
||||
return tagPaging;
|
||||
}), catchError((error) => this.handleError(error)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user