mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
ACS-7689 Save and delete to existing hold (#9841)
This commit is contained in:
committed by
Darya Blavanovich
parent
bf7f202b91
commit
206f2e02ea
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { ContentPagingQuery, Hold, LegalHoldApi } from '@alfresco/js-api';
|
||||
import { ContentPagingQuery, Hold, HoldEntry, HoldPaging, LegalHoldApi } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
@@ -50,4 +50,37 @@ export class LegalHoldService {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a node to a hold.
|
||||
*
|
||||
* @param nodeId The Id of the node which will be assigned to a hold
|
||||
* @param holdId The Id of the hold to which nodes will be assigned
|
||||
* @returns Observable<HoldEntry>
|
||||
*/
|
||||
assignHold(nodeId: string, holdId: string): Observable<HoldEntry> {
|
||||
return from(this.legalHoldApi.assignHold(nodeId, holdId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign a node to a hold.
|
||||
*
|
||||
* @param nodeIds The list of managed node Ids
|
||||
* @param holdId The Id of the hold to which nodes will be assigned
|
||||
* @returns Observable<HoldPaging>
|
||||
*/
|
||||
assignHolds(nodeIds: { id: string }[], holdId: string): Observable<HoldPaging> {
|
||||
return from(this.legalHoldApi.assignHolds(nodeIds, holdId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Unassign the relationship between a child with id nodeId and a parent hold with id holdId.
|
||||
*
|
||||
* @param holdId The hold Id
|
||||
* @param nodeId The Id of the node which is unassigned
|
||||
* @returns Empty response
|
||||
*/
|
||||
unassignHold(holdId: string, nodeId: string): Observable<void> {
|
||||
return from(this.legalHoldApi.unassignHold(holdId, nodeId));
|
||||
}
|
||||
}
|
||||
|
@@ -71,4 +71,47 @@ describe('LegalHoldsService', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('assignHold', () => {
|
||||
it('should assign node to existing hold', (done) => {
|
||||
const nodeId = 'qwe';
|
||||
const holdId = 'foo';
|
||||
const mockResponse = { entry: { id: holdId } };
|
||||
spyOn(service.legalHoldApi, 'assignHold').and.returnValue(Promise.resolve(mockResponse));
|
||||
|
||||
service.assignHold(nodeId, holdId).subscribe((holds) => {
|
||||
expect(holds).toEqual(mockResponse);
|
||||
expect(service.legalHoldApi.assignHold).toHaveBeenCalledWith(nodeId, holdId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('assignHolds', () => {
|
||||
it('should assign nodes to existing hold', (done) => {
|
||||
const nodeIds = [{ id: 'qwe' }, { id: 'abc'}];
|
||||
const holdId = 'foo';
|
||||
spyOn(service.legalHoldApi, 'assignHolds').and.returnValue(Promise.resolve(legalHolds));
|
||||
|
||||
service.assignHolds(nodeIds, holdId).subscribe((holds) => {
|
||||
expect(holds).toEqual(legalHolds);
|
||||
expect(service.legalHoldApi.assignHolds).toHaveBeenCalledWith(nodeIds, holdId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('unassignHold', () => {
|
||||
it('should unassign node from existing hold', (done) => {
|
||||
const nodeId = 'qwe';
|
||||
const holdId = 'foo';
|
||||
|
||||
spyOn(service.legalHoldApi, 'unassignHold').and.returnValue(Promise.resolve(undefined));
|
||||
|
||||
service.unassignHold(holdId, nodeId).subscribe(() => {
|
||||
expect(service.legalHoldApi.unassignHold).toHaveBeenCalledWith(holdId, nodeId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user