Merge pull request #2146 from amgciadev/fix-1702-b

Fix #1702 - Move item collection with inheritPolicies support
This commit is contained in:
Tim Donohue
2023-04-14 14:50:29 -05:00
committed by GitHub
3 changed files with 7 additions and 6 deletions

View File

@@ -246,10 +246,10 @@ export abstract class BaseItemDataService extends IdentifiableDataService<Item>
* Get the endpoint to move the item * Get the endpoint to move the item
* @param itemId * @param itemId
*/ */
public getMoveItemEndpoint(itemId: string): Observable<string> { public getMoveItemEndpoint(itemId: string, inheritPolicies: boolean): Observable<string> {
return this.halService.getEndpoint(this.linkPath).pipe( return this.halService.getEndpoint(this.linkPath).pipe(
map((endpoint: string) => this.getIDHref(endpoint, itemId)), 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 itemId
* @param collection * @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({}); const options: HttpOptions = Object.create({});
let headers = new HttpHeaders(); let headers = new HttpHeaders();
headers = headers.append('Content-Type', 'text/uri-list'); headers = headers.append('Content-Type', 'text/uri-list');
options.headers = headers; options.headers = headers;
const requestId = this.requestService.generateRequestId(); const requestId = this.requestService.generateRequestId();
const hrefObs = this.getMoveItemEndpoint(itemId); const hrefObs = this.getMoveItemEndpoint(itemId, inheritPolicies);
hrefObs.pipe( hrefObs.pipe(
find((href: string) => hasValue(href)), find((href: string) => hasValue(href)),

View File

@@ -134,9 +134,10 @@ describe('ItemMoveComponent', () => {
}); });
comp.selectedCollectionName = 'selected-collection-id'; comp.selectedCollectionName = 'selected-collection-id';
comp.selectedCollection = collection1; comp.selectedCollection = collection1;
comp.inheritPolicies = false;
comp.moveToCollection(); 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', () => { it('should call notificationsService success message on success', () => {
comp.moveToCollection(); comp.moveToCollection();

View File

@@ -104,7 +104,7 @@ export class ItemMoveComponent implements OnInit {
*/ */
moveToCollection() { moveToCollection() {
this.processing = true; 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()); .pipe(getFirstCompletedRemoteData());
move$.subscribe((response: RemoteData<any>) => { move$.subscribe((response: RemoteData<any>) => {