mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
ACS-7589 Save holds, delete holds
This commit is contained in:
@@ -51,4 +51,43 @@ export class LegalHoldService {
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a child of a hold with id holdId.
|
||||
*
|
||||
* @param ids The list of manage hold Ids
|
||||
* @param holdId The Id of the hold to witch children will be added
|
||||
* @returns List of assigned holds Hold[]
|
||||
*/
|
||||
addHoldsToExistingHold(ids: string[], holdId: string): Observable<Hold[]> {
|
||||
return from(this.legalHoldApi.saveToExistingHolds(ids, holdId)).pipe(
|
||||
map(({ list }) =>
|
||||
list?.entries?.map(({ entry }) => ({
|
||||
id: entry?.id,
|
||||
name: entry?.name,
|
||||
}))
|
||||
),
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the relationship between a child with id holdChildId and a parent hold with id holdId.
|
||||
*
|
||||
* @param holdId The handled hold Id
|
||||
* @param holdChildId The Id of the child hold which is removed
|
||||
* @returns List of assigned holds Hold[]
|
||||
*/
|
||||
deleteHoldFromExistingHold(holdId: string, holdChildId: string): Observable<Hold[]> {
|
||||
return from(this.legalHoldApi.deleteFromExistingHolds(holdId, holdChildId)).pipe(
|
||||
map(({ list }) =>
|
||||
list?.entries?.map(({ entry }) => ({
|
||||
id: entry?.id,
|
||||
name: entry?.name,
|
||||
}))
|
||||
),
|
||||
catchError((err) => throwError(err))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,4 +71,30 @@ describe('LegalHoldsService', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('addHoldsToExistingHold', () => {
|
||||
it('should add holds to existing hold', (done) => {
|
||||
const childrenIds = ['abc', 'qwe'];
|
||||
spyOn(service.legalHoldApi, 'saveToExistingHolds').and.returnValue(Promise.resolve(legalHolds));
|
||||
|
||||
service.addHoldsToExistingHold(childrenIds, mockId).subscribe((holds) => {
|
||||
expect(holds).toEqual(returnedHolds);
|
||||
expect(service.legalHoldApi.saveToExistingHolds).toHaveBeenCalledWith(mockId, childrenIds);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteHoldFromExistingHold', () => {
|
||||
it('should delete hold from existing hold', (done) => {
|
||||
const childrenId = 'qwe';
|
||||
spyOn(service.legalHoldApi, 'deleteFromExistingHolds').and.returnValue(Promise.resolve(legalHolds));
|
||||
|
||||
service.deleteHoldFromExistingHold(mockId, childrenId).subscribe((holds) => {
|
||||
expect(holds).toEqual(returnedHolds);
|
||||
expect(service.legalHoldApi.deleteFromExistingHolds).toHaveBeenCalledWith(mockId, childrenId);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -52,4 +52,40 @@ export class LegalHoldApi extends BaseApi {
|
||||
returnType: HoldPaging
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to existing hold
|
||||
*
|
||||
* @param holdId The identifier of a hold.
|
||||
* @param ids list of ids of holds to add to existing hold
|
||||
* @returns Promise<NodeChildAssociationPaging>
|
||||
*/
|
||||
saveToExistingHolds(ids: string[], holdId: string): Promise<HoldPaging> {
|
||||
throwIfNotDefined(holdId, 'holdId');
|
||||
|
||||
return this.post({
|
||||
path: `/holds/{holdId}/children`,
|
||||
pathParams: { holdId },
|
||||
bodyParam: ids,
|
||||
returnType: HoldPaging
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the relationship between a child with id holdChildId and a parent hold with id holdId.
|
||||
*
|
||||
* @param holdId The handled hold Id
|
||||
* @param holdChildId The Id of the child hold which is removed
|
||||
* @returns List of assigned holds Hold[]
|
||||
*/
|
||||
deleteFromExistingHolds(holdId: string, holdChildId: string): Promise<HoldPaging> {
|
||||
throwIfNotDefined(holdId, 'holdId');
|
||||
throwIfNotDefined(holdChildId, 'holdChildId');
|
||||
|
||||
return this.delete({
|
||||
path: `/holds/{holdId}/children/{holdChildId}`,
|
||||
pathParams: { holdId, holdChildId },
|
||||
returnType: HoldPaging
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user