80195: Refresh moved Item's owningCollection before redirecting

This commit is contained in:
Yura Bondarenko
2021-06-23 11:57:16 +02:00
parent 0ac9d58194
commit 2c19d80a16
2 changed files with 11 additions and 4 deletions

View File

@@ -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 = {

View File

@@ -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<any>) => {
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;
}
);
}