Skip to content

Commit 3fcb113

Browse files
authored
Merge pull request DSpace#2146 from amgciadev/fix-1702-b
Fix DSpace#1702 - Move item collection with inheritPolicies support
2 parents 548ccf8 + 50d3623 commit 3fcb113

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/app/core/data/item-data.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
246246
* Get the endpoint to move the item
247247
* @param itemId
248248
*/
249-
public getMoveItemEndpoint(itemId: string): Observable<string> {
249+
public getMoveItemEndpoint(itemId: string, inheritPolicies: boolean): Observable<string> {
250250
return this.halService.getEndpoint(this.linkPath).pipe(
251251
map((endpoint: string) => this.getIDHref(endpoint, itemId)),
252-
map((endpoint: string) => `${endpoint}/owningCollection`),
252+
map((endpoint: string) => `${endpoint}/owningCollection?inheritPolicies=${inheritPolicies}`)
253253
);
254254
}
255255

@@ -258,14 +258,14 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
258258
* @param itemId
259259
* @param collection
260260
*/
261-
public moveToCollection(itemId: string, collection: Collection): Observable<RemoteData<any>> {
261+
public moveToCollection(itemId: string, collection: Collection, inheritPolicies: boolean): Observable<RemoteData<any>> {
262262
const options: HttpOptions = Object.create({});
263263
let headers = new HttpHeaders();
264264
headers = headers.append('Content-Type', 'text/uri-list');
265265
options.headers = headers;
266266

267267
const requestId = this.requestService.generateRequestId();
268-
const hrefObs = this.getMoveItemEndpoint(itemId);
268+
const hrefObs = this.getMoveItemEndpoint(itemId, inheritPolicies);
269269

270270
hrefObs.pipe(
271271
find((href: string) => hasValue(href)),

src/app/item-page/edit-item-page/item-move/item-move.component.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@ describe('ItemMoveComponent', () => {
134134
});
135135
comp.selectedCollectionName = 'selected-collection-id';
136136
comp.selectedCollection = collection1;
137+
comp.inheritPolicies = false;
137138
comp.moveToCollection();
138139

139-
expect(itemDataService.moveToCollection).toHaveBeenCalledWith('item-id', collection1);
140+
expect(itemDataService.moveToCollection).toHaveBeenCalledWith('item-id', collection1, false);
140141
});
141142
it('should call notificationsService success message on success', () => {
142143
comp.moveToCollection();

src/app/item-page/edit-item-page/item-move/item-move.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ItemMoveComponent implements OnInit {
104104
*/
105105
moveToCollection() {
106106
this.processing = true;
107-
const move$ = this.itemDataService.moveToCollection(this.item.id, this.selectedCollection)
107+
const move$ = this.itemDataService.moveToCollection(this.item.id, this.selectedCollection, this.inheritPolicies)
108108
.pipe(getFirstCompletedRemoteData());
109109

110110
move$.subscribe((response: RemoteData<any>) => {

0 commit comments

Comments
 (0)