mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
[CST-5674] Error handling; fixes
This commit is contained in:
@@ -235,15 +235,16 @@ export class ResourcePolicyService {
|
||||
|
||||
/**
|
||||
* Update the target of the resource policy
|
||||
* @param resourcePolicyId the ID of the resource policy
|
||||
* @param resourcePolicyHref the link to the resource policy
|
||||
* @param uuid the UUID of the target to which the permission is being granted
|
||||
* @param type the type of the target (eperson or group) to which the permission is being granted
|
||||
*/
|
||||
updateTarget(resourcePolicyHref: string, uuid: string, type: string): Observable<RemoteData<any>> {
|
||||
updateTarget(resourcePolicyId: string, resourcePolicyHref: string, uuid: string, type: string): Observable<RemoteData<any>> {
|
||||
|
||||
const targetService = type === 'eperson' ? this.ePersonService : this.groupService;
|
||||
|
||||
const ep$ = targetService.getBrowseEndpoint().pipe(
|
||||
const targetEndpoint$ = targetService.getBrowseEndpoint().pipe(
|
||||
take(1),
|
||||
map((endpoint: string) =>`${endpoint}/${uuid}`),
|
||||
);
|
||||
@@ -255,8 +256,11 @@ export class ResourcePolicyService {
|
||||
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
|
||||
return ep$.pipe(switchMap((ep) => {
|
||||
const request = new PostRequest(requestId, resourcePolicyHref, ep, options);
|
||||
this.requestService.setStaleByHrefSubstring(`${this.dataService.getLinkPath()}/${resourcePolicyId}/${type}`);
|
||||
|
||||
return targetEndpoint$.pipe(switchMap((targetEndpoint) => {
|
||||
const resourceEndpoint = resourcePolicyHref + '/' + type
|
||||
const request = new PostRequest(requestId, resourceEndpoint, targetEndpoint, options);
|
||||
Object.assign(request, {
|
||||
getResponseParser(): GenericConstructor<ResponseParsingService> {
|
||||
return StatusCodeOnlyResponseParsingService;
|
||||
|
@@ -90,7 +90,7 @@ export class ResourcePolicyEditComponent implements OnInit {
|
||||
});
|
||||
|
||||
const updateTargetSucceeded$ = event.updateTarget ? this.resourcePolicyService.updateTarget(
|
||||
this.resourcePolicy._links.self.href, event.target.uuid, event.target.type
|
||||
this.resourcePolicy.id, this.resourcePolicy._links.self.href, event.target.uuid, event.target.type
|
||||
).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((responseRD) => responseRD && responseRD.hasSucceeded)
|
||||
@@ -107,7 +107,11 @@ export class ResourcePolicyEditComponent implements OnInit {
|
||||
if (updateTargetSucceeded && updateResourcePolicySucceeded) {
|
||||
this.notificationsService.success(null, this.translate.get('resource-policies.edit.page.success.content'));
|
||||
this.redirectToAuthorizationsPage();
|
||||
} else {
|
||||
} else if (updateResourcePolicySucceeded) { // everything except target has been updated
|
||||
this.notificationsService.error(null, this.translate.get('resource-policies.edit.page.target-failure.content'));
|
||||
} else if (updateTargetSucceeded) { // only target has been updated
|
||||
this.notificationsService.error(null, this.translate.get('resource-policies.edit.page.other-failure.content'));
|
||||
} else { // nothing has been updated
|
||||
this.notificationsService.error(null, this.translate.get('resource-policies.edit.page.failure.content'));
|
||||
}
|
||||
}
|
||||
|
@@ -3122,6 +3122,10 @@
|
||||
|
||||
"resource-policies.edit.page.failure.content": "An error occurred while editing the resource policy.",
|
||||
|
||||
"resource-policies.edit.page.target-failure.content": "An error occurred while editing the target (ePerson or group) of the resource policy.",
|
||||
|
||||
"resource-policies.edit.page.other-failure.content": "An error occurred while editing the resource policy. The target (ePerson or group) has been successfully updated.",
|
||||
|
||||
"resource-policies.edit.page.success.content": "Operation successful",
|
||||
|
||||
"resource-policies.edit.page.title": "Edit resource policy",
|
||||
|
Reference in New Issue
Block a user