diff --git a/docs/content-services/services/custom-resources.service.md b/docs/content-services/services/custom-resources.service.md
index fdb9955fdc..84492dff3e 100644
--- a/docs/content-services/services/custom-resources.service.md
+++ b/docs/content-services/services/custom-resources.service.md
@@ -23,11 +23,12 @@ Manages Document List information that is specific to a user.
- _node:_ `any` - Node object
- _nodeId:_ `string` - ID of the node object
- **Returns** `string` - ID value
-- **getRecentFiles**(personId: `string`, pagination: [`PaginationModel`](../../../lib/core/src/lib/models/pagination.model.ts), filters?: `string[]`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/NodePaging.md)`>`
+- **getRecentFiles**(personId: `string`, pagination: [`PaginationModel`](../../../lib/core/src/lib/models/pagination.model.ts), filters?: `string[]`, includeFields: `string[]` = `[]`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/NodePaging.md)`>`
Gets files recently accessed by a user.
- _personId:_ `string` - ID of the user
- _pagination:_ [`PaginationModel`](../../../lib/core/src/lib/models/pagination.model.ts) - Specifies how to paginate the results
- _filters:_ `string[]` - (Optional) Specifies additional filters to apply (joined with **AND**)
+ - _includeFields:_ `string[]` - List of data field names to include in the results
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodePaging`](https://github.com/Alfresco/alfresco-js-api/blob/develop/src/api/content-rest-api/docs/NodePaging.md)`>` - List of nodes for the recently used files
- **hasCorrespondingNodeIds**(nodeId: `string`): `boolean`
Does the well-known alias have a corresponding node ID?
diff --git a/lib/content-services/src/lib/document-list/services/custom-resources.service.spec.ts b/lib/content-services/src/lib/document-list/services/custom-resources.service.spec.ts
index bc943e4e23..400d369985 100644
--- a/lib/content-services/src/lib/document-list/services/custom-resources.service.spec.ts
+++ b/lib/content-services/src/lib/document-list/services/custom-resources.service.spec.ts
@@ -24,6 +24,9 @@ import {
FavoritePagingList,
NodeEntry,
NodePaging,
+ Person,
+ PersonEntry,
+ ResultSetPaging,
Site,
SiteEntry,
SiteMember,
@@ -194,7 +197,57 @@ describe('CustomResourcesService', () => {
spyOn(customResourcesService, 'getRecentFiles').and.stub();
customResourcesService.loadFolderByNodeId('-recent-', pagination, ['include'], 'where', ['filters']);
- expect(customResourcesService.getRecentFiles).toHaveBeenCalledWith('-me-', pagination, ['filters']);
+ expect(customResourcesService.getRecentFiles).toHaveBeenCalledWith('-me-', pagination, ['filters'], ['include']);
+ });
+ });
+
+ describe('getRecentFiles', () => {
+ const pagination: PaginationModel = { maxItems: 100, skipCount: 0 };
+
+ beforeEach(() => {
+ spyOn(customResourcesService.peopleApi, 'getPerson').and.returnValue(
+ Promise.resolve(new PersonEntry({ entry: new Person({ id: 'user' }) }))
+ );
+ });
+
+ it('should pass includeFields through to the search request, keeping the defaults', (done) => {
+ const searchSpy = spyOn(customResourcesService.searchApi, 'search').and.returnValue(Promise.resolve(new ResultSetPaging()));
+
+ customResourcesService.getRecentFiles('-me-', pagination, undefined, ['isFavorite']).subscribe(() => {
+ expect(searchSpy).toHaveBeenCalledTimes(1);
+ expect(searchSpy.calls.mostRecent().args[0].include).toEqual([
+ 'path',
+ 'properties',
+ 'allowableOperations',
+ 'aspectNames',
+ 'isFavorite'
+ ]);
+ done();
+ });
+ });
+
+ it('should keep the default include fields when no includeFields are provided', (done) => {
+ const searchSpy = spyOn(customResourcesService.searchApi, 'search').and.returnValue(Promise.resolve(new ResultSetPaging()));
+
+ customResourcesService.getRecentFiles('-me-', pagination).subscribe(() => {
+ expect(searchSpy.calls.mostRecent().args[0].include).toEqual(['path', 'properties', 'allowableOperations', 'aspectNames']);
+ done();
+ });
+ });
+
+ it('should not duplicate an includeField that is already a default', (done) => {
+ const searchSpy = spyOn(customResourcesService.searchApi, 'search').and.returnValue(Promise.resolve(new ResultSetPaging()));
+
+ customResourcesService.getRecentFiles('-me-', pagination, undefined, ['properties', 'isFavorite']).subscribe(() => {
+ expect(searchSpy.calls.mostRecent().args[0].include).toEqual([
+ 'path',
+ 'properties',
+ 'allowableOperations',
+ 'aspectNames',
+ 'isFavorite'
+ ]);
+ done();
+ });
});
});
diff --git a/lib/content-services/src/lib/document-list/services/custom-resources.service.ts b/lib/content-services/src/lib/document-list/services/custom-resources.service.ts
index 763a70ef13..461c1a6fc8 100644
--- a/lib/content-services/src/lib/document-list/services/custom-resources.service.ts
+++ b/lib/content-services/src/lib/document-list/services/custom-resources.service.ts
@@ -73,9 +73,10 @@ export class CustomResourcesService {
* @param personId ID of the user
* @param pagination Specifies how to paginate the results
* @param filters Specifies additional filters to apply (joined with **AND**)
+ * @param includeFields List of data field names to include in the results
* @returns List of nodes for the recently used files
*/
- getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[]): Observable {
+ getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[], includeFields: string[] = []): Observable {
const defaultFilter = [
'TYPE:"content"',
'-PATH:"//cm:wiki/*"',
@@ -121,7 +122,7 @@ export class CustomResourcesService {
language: SEARCH_LANGUAGE.AFTS
},
filterQueries,
- include: ['path', 'properties', 'allowableOperations', 'aspectNames'],
+ include: [...new Set(['path', 'properties', 'allowableOperations', 'aspectNames', ...includeFields])],
sort: [
{
type: 'FIELD',
@@ -380,7 +381,7 @@ export class CustomResourcesService {
} else if (nodeId === '-favorites-') {
return this.loadFavorites(pagination, includeFields, where);
} else if (nodeId === '-recent-') {
- return this.getRecentFiles('-me-', pagination, filters);
+ return this.getRecentFiles('-me-', pagination, filters, includeFields);
} else {
return of(null);
}