From 2c19d80a16ffb25bad4b07d10b3dcbbe1ff34b8b Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Wed, 23 Jun 2021 11:57:16 +0200 Subject: [PATCH] 80195: Refresh moved Item's owningCollection before redirecting --- .../edit-item-page/item-move/item-move.component.spec.ts | 6 ++++-- .../edit-item-page/item-move/item-move.component.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/app/+item-page/edit-item-page/item-move/item-move.component.spec.ts b/src/app/+item-page/edit-item-page/item-move/item-move.component.spec.ts index b3178793e3..2a51dcc06d 100644 --- a/src/app/+item-page/edit-item-page/item-move/item-move.component.spec.ts +++ b/src/app/+item-page/edit-item-page/item-move/item-move.component.spec.ts @@ -48,11 +48,13 @@ describe('ItemMoveComponent', () => { }); const mockItemDataService = jasmine.createSpyObj({ - moveToCollection: createSuccessfulRemoteDataObject$(collection1) + moveToCollection: createSuccessfulRemoteDataObject$(collection1), + findById: createSuccessfulRemoteDataObject$(mockItem), }); const mockItemDataServiceFail = jasmine.createSpyObj({ - moveToCollection: createFailedRemoteDataObject$('Internal server error', 500) + moveToCollection: createFailedRemoteDataObject$('Internal server error', 500), + findById: createSuccessfulRemoteDataObject$(mockItem), }); const routeStub = { diff --git a/src/app/+item-page/edit-item-page/item-move/item-move.component.ts b/src/app/+item-page/edit-item-page/item-move/item-move.component.ts index c80b0f7477..9c6670ef26 100644 --- a/src/app/+item-page/edit-item-page/item-move/item-move.component.ts +++ b/src/app/+item-page/edit-item-page/item-move/item-move.component.ts @@ -14,6 +14,7 @@ import { Observable, of as observableOf } from 'rxjs'; import { Collection } from '../../../core/shared/collection.model'; import { SearchService } from '../../../core/shared/search/search.service'; import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths'; +import { followLink } from '../../../shared/utils/follow-link-config.model'; @Component({ selector: 'ds-item-move', @@ -93,13 +94,17 @@ export class ItemMoveComponent implements OnInit { .pipe(getFirstCompletedRemoteData()) .subscribe( (response: RemoteData) => { - this.router.navigate([getItemEditRoute(this.item)]); + this.itemDataService.findById( + this.item.id, false, true, followLink('owningCollection', undefined, true, false) + ).subscribe(() => { + this.processing = false; + this.router.navigate([getItemEditRoute(this.item)]); + }); if (response.hasSucceeded) { this.notificationsService.success(this.translateService.get('item.edit.move.success')); } else { this.notificationsService.error(this.translateService.get('item.edit.move.error')); } - this.processing = false; } ); }