diff --git a/src/app/core/shared/operators.ts b/src/app/core/shared/operators.ts index e98a0cee7b..a9c01689b2 100644 --- a/src/app/core/shared/operators.ts +++ b/src/app/core/shared/operators.ts @@ -76,6 +76,10 @@ export const getSucceededRemoteWithNotEmptyData = () => (source: Observable>): Observable> => source.pipe(find((rd: RemoteData) => rd.hasSucceeded && isNotEmpty(rd.payload))); +export const getSucceededRemoteWithNotEmptyDataOrFailed = () => + (source: Observable>): Observable> => + source.pipe(find((rd: RemoteData) => (rd.hasSucceeded && isNotEmpty(rd.payload)) || rd.hasFailed)); + export const getSucceededOrNoContentResponse = () => (source: Observable>): Observable> => source.pipe(find((rd: RemoteData) => rd.hasSucceeded || rd.hasNoContent)); diff --git a/src/app/shared/resource-policies/edit/resource-policy-edit.component.ts b/src/app/shared/resource-policies/edit/resource-policy-edit.component.ts index dce33ea122..dceb485fb6 100644 --- a/src/app/shared/resource-policies/edit/resource-policy-edit.component.ts +++ b/src/app/shared/resource-policies/edit/resource-policy-edit.component.ts @@ -12,7 +12,7 @@ import { ResourcePolicy } from '../../../core/resource-policy/models/resource-po import { ResourcePolicyEvent } from '../form/resource-policy-form.component'; import { RESOURCE_POLICY } from '../../../core/resource-policy/models/resource-policy.resource-type'; import { ITEM_EDIT_AUTHORIZATIONS_PATH } from '../../../+item-page/edit-item-page/edit-item-page.routing-paths'; -import { getSucceededRemoteWithNotEmptyData } from '../../../core/shared/operators'; +import { getSucceededRemoteWithNotEmptyDataOrFailed } from '../../../core/shared/operators'; @Component({ selector: 'ds-resource-policy-edit', @@ -89,11 +89,11 @@ export class ResourcePolicyEditComponent implements OnInit { _links: this.resourcePolicy._links }); this.resourcePolicyService.update(updatedObject).pipe( - getSucceededRemoteWithNotEmptyData(), + getSucceededRemoteWithNotEmptyDataOrFailed(), take(1) ).subscribe((responseRD: RemoteData) => { this.processing$.next(false); - if (responseRD.hasSucceeded) { + if (responseRD && responseRD.hasSucceeded) { this.notificationsService.success(null, this.translate.get('resource-policies.edit.page.success.content')); this.redirectToAuthorizationsPage(); } else {