mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[MNT-25478] Expose list parents method in nodes api service (#11622)
* [MNT-25478] Expose list parents method in nodes api service * [MNT-25478] CR fixes
This commit is contained in:
@@ -98,6 +98,11 @@ Accesses and manipulates ACS document nodes using their node IDs.
|
||||
- _nodeId:_ `string` - ID of the target node
|
||||
- _jobId:_ `string` - ID of the job started by the `initiateFolderSizeCalculation` request
|
||||
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`SizeDetailsEntry`](../../../lib/js-api/src/api/content-rest-api/docs/NodesApi.md#sizedetailsentry)`>` - Details of the folder
|
||||
- **listParents**(nodeId: `string`, opts: `{ where?: string; includeSource?: boolean;} & NodesIncludeQuery & ContentPagingQuery`): [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodeAssociationPaging`](../../../lib/js-api/src/api/content-rest-api/docs/NodesApi.md#NodeAssociationPaging)`>`<br/>
|
||||
Lists parents of a node.
|
||||
- _nodeId:_ `string` - ID of the target node
|
||||
- _opts:_ `{ where?: string; includeSource?: boolean;} & NodesIncludeQuery & ContentPagingQuery` - additional options that API can take
|
||||
- **Returns** [`Observable`](http://reactivex.io/documentation/observable.html)`<`[`NodeAssociationPaging`](../../../lib/js-api/src/api/content-rest-api/docs/NodesApi.md#NodeAssociationPaging)`>` - List of node's parents.
|
||||
|
||||
## Details
|
||||
|
||||
|
||||
@@ -68,4 +68,11 @@ describe('NodesApiService', () => {
|
||||
|
||||
expect(nodesApiService.nodesApi.getFolderSizeInfo).toHaveBeenCalledWith('fake-node-id', 'fake-job-id');
|
||||
});
|
||||
|
||||
it('should call listParents api with nodeId and optional params', async () => {
|
||||
spyOn(nodesApiService.nodesApi, 'listParents').and.returnValue(Promise.resolve({ list: { entries: [] } }));
|
||||
await firstValueFrom(nodesApiService.listParents('fake-node-id', { include: ['path'], where: 'isPrimary=true' }));
|
||||
|
||||
expect(nodesApiService.nodesApi.listParents).toHaveBeenCalledWith('fake-node-id', { include: ['path'], where: 'isPrimary=true' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,7 +26,8 @@ import {
|
||||
NodesIncludeQuery,
|
||||
TrashcanApi,
|
||||
SizeDetailsEntry,
|
||||
JobIdBodyEntry
|
||||
JobIdBodyEntry,
|
||||
NodeAssociationPaging
|
||||
} from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { from, Observable, Subject, throwError } from 'rxjs';
|
||||
@@ -55,7 +56,10 @@ export class NodesApiService {
|
||||
return this._nodesApi;
|
||||
}
|
||||
|
||||
constructor(private apiService: AlfrescoApiService, private preferences: UserPreferencesService) {}
|
||||
constructor(
|
||||
private readonly apiService: AlfrescoApiService,
|
||||
private readonly preferences: UserPreferencesService
|
||||
) {}
|
||||
|
||||
private getEntryFromEntity(entity: NodeEntry): Node {
|
||||
return entity.entry;
|
||||
@@ -278,6 +282,24 @@ export class NodesApiService {
|
||||
return from(this.nodesApi.getFolderSizeInfo(nodeId, jobId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists parents of a given node.
|
||||
*
|
||||
* @param nodeId Node ID
|
||||
* @param opts Optional parameters
|
||||
* @returns List of parent nodes
|
||||
*/
|
||||
listParents(
|
||||
nodeId: string,
|
||||
opts?: {
|
||||
where?: string;
|
||||
includeSource?: boolean;
|
||||
} & NodesIncludeQuery &
|
||||
ContentPagingQuery
|
||||
): Observable<NodeAssociationPaging> {
|
||||
return from(this.nodesApi.listParents(nodeId, opts));
|
||||
}
|
||||
|
||||
private randomNodeName(): string {
|
||||
return `node_${Date.now()}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user