mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-02 17:53:30 +00:00
[ACS-12286] Pass includeFields through to getRecentFiles for -recent- (#12067)
* [ACS-12286] Pass includeFields through to getRecentFiles for -recent- loadFolderByNodeId forwarded includeFields to every custom source except -recent-, and getRecentFiles had no includeFields parameter, hardcoding the search include set. Thread includeFields through to the recent-files search request (de-duplicated, defaults preserved) so callers can request extra fields such as isFavorite. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [ACS-12286] Document includeFields parameter for getRecentFiles Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [ACS-12286] Use typed PersonEntry instead of any in getRecentFiles spec Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
b69c3ae1ae
commit
0a19be090e
@@ -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)`>`<br/>
|
||||
- **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)`>`<br/>
|
||||
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`<br/>
|
||||
Does the well-known alias have a corresponding node ID?
|
||||
|
||||
+54
-1
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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<ResultSetPaging> {
|
||||
getRecentFiles(personId: string, pagination: PaginationModel, filters?: string[], includeFields: string[] = []): Observable<ResultSetPaging> {
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user