mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Add support to send inheritPolicies flag when moving item collection
This commit is contained in:
@@ -246,10 +246,10 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
|
||||
* Get the endpoint to move the item
|
||||
* @param itemId
|
||||
*/
|
||||
public getMoveItemEndpoint(itemId: string): Observable<string> {
|
||||
public getMoveItemEndpoint(itemId: string, inheritPolicies: boolean): Observable<string> {
|
||||
return this.halService.getEndpoint(this.linkPath).pipe(
|
||||
map((endpoint: string) => this.getIDHref(endpoint, itemId)),
|
||||
map((endpoint: string) => `${endpoint}/owningCollection`),
|
||||
map((endpoint: string) => `${endpoint}/owningCollection?inheritPolicies=${inheritPolicies}`)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -258,14 +258,14 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
|
||||
* @param itemId
|
||||
* @param collection
|
||||
*/
|
||||
public moveToCollection(itemId: string, collection: Collection): Observable<RemoteData<any>> {
|
||||
public moveToCollection(itemId: string, collection: Collection, inheritPolicies: boolean): Observable<RemoteData<any>> {
|
||||
const options: HttpOptions = Object.create({});
|
||||
let headers = new HttpHeaders();
|
||||
headers = headers.append('Content-Type', 'text/uri-list');
|
||||
options.headers = headers;
|
||||
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
const hrefObs = this.getMoveItemEndpoint(itemId);
|
||||
const hrefObs = this.getMoveItemEndpoint(itemId, inheritPolicies);
|
||||
|
||||
hrefObs.pipe(
|
||||
find((href: string) => hasValue(href)),
|
||||
|
@@ -134,9 +134,10 @@ describe('ItemMoveComponent', () => {
|
||||
});
|
||||
comp.selectedCollectionName = 'selected-collection-id';
|
||||
comp.selectedCollection = collection1;
|
||||
comp.inheritPolicies = false;
|
||||
comp.moveToCollection();
|
||||
|
||||
expect(itemDataService.moveToCollection).toHaveBeenCalledWith('item-id', collection1);
|
||||
expect(itemDataService.moveToCollection).toHaveBeenCalledWith('item-id', collection1, false);
|
||||
});
|
||||
it('should call notificationsService success message on success', () => {
|
||||
comp.moveToCollection();
|
||||
|
@@ -104,7 +104,7 @@ export class ItemMoveComponent implements OnInit {
|
||||
*/
|
||||
moveToCollection() {
|
||||
this.processing = true;
|
||||
const move$ = this.itemDataService.moveToCollection(this.item.id, this.selectedCollection)
|
||||
const move$ = this.itemDataService.moveToCollection(this.item.id, this.selectedCollection, this.inheritPolicies)
|
||||
.pipe(getFirstCompletedRemoteData());
|
||||
|
||||
move$.subscribe((response: RemoteData<any>) => {
|
||||
|
Reference in New Issue
Block a user