redirect back to the list after an eperson add, edit or delete

This commit is contained in:
Art Lowel
2021-01-27 18:09:36 +01:00
parent 892512192b
commit 15495902ab
2 changed files with 7 additions and 4 deletions

View File

@@ -283,7 +283,10 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
this.epersonService.getBrowseEndpoint().pipe(
take(1)
).subscribe((href: string) => {
this.requestService.setStaleByHrefSubstring(href);
this.requestService.setStaleByHrefSubstring(href).pipe(take(1)).subscribe(() => {
this.epersonService.cancelEditEPerson();
this.isEPersonFormShown = false;
});
});
}
}

View File

@@ -359,7 +359,7 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
});
const response = this.epersonService.updateEPerson(editedEperson);
response.pipe(take(1)).subscribe((rd: RemoteData<EPerson>) => {
response.pipe(getFirstCompletedRemoteData()).subscribe((rd: RemoteData<EPerson>) => {
if (rd.hasSucceeded) {
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.edited.success', { name: editedEperson.name }));
this.submitForm.emit(editedEperson);
@@ -439,10 +439,10 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
modalRef.componentInstance.response.pipe(take(1)).subscribe((confirm: boolean) => {
if (confirm) {
if (hasValue(eperson.id)) {
this.epersonService.deleteEPerson(eperson).pipe(take(1)).subscribe((restResponse: RemoteData<NoContent>) => {
this.epersonService.deleteEPerson(eperson).pipe(getFirstCompletedRemoteData()).subscribe((restResponse: RemoteData<NoContent>) => {
if (restResponse.hasSucceeded) {
this.notificationsService.success(this.translateService.get(this.labelPrefix + 'notification.deleted.success', { name: eperson.name }));
this.reset();
this.submitForm.emit();
} else {
this.notificationsService.error('Error occured when trying to delete EPerson with id: ' + eperson.id + ' with code: ' + restResponse.statusCode + ' and message: ' + restResponse.errorMessage);
}