Skip to content

Commit 31cafeb

Browse files
[DURACOM-453] port error parsing in edit mode
1 parent c352534 commit 31cafeb

15 files changed

Lines changed: 115 additions & 27 deletions

src/app/core/cache/builders/remote-data-build.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ export class RemoteDataBuildService {
339339
response.errorMessage,
340340
payload,
341341
response.statusCode,
342+
response.errors,
342343
);
343344
}),
344345
);

src/app/core/json-patch/json-patch-operations.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export abstract class JsonPatchOperationsService<ResponseDefinitionDomain, Patch
112112
map((rd: RemoteData<any>) => {
113113
if (rd.hasFailed) {
114114
this.store.dispatch(new RollbacktPatchOperationsAction(resourceType, resourceId));
115-
throw new Error(rd.errorMessage);
115+
throw rd as unknown as Error;
116116
} else if (hasValue(rd.payload) && isNotEmpty(rd.payload.dataDefinition)) {
117117
this.store.dispatch(new CommitPatchOperationsAction(resourceType, resourceId));
118118
return rd.payload.dataDefinition;

src/app/core/submission/models/submission-object.model.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { PathableObjectError } from '@dspace/core/data/response-state.model';
12
import {
23
autoserialize,
34
deserialize,
@@ -22,10 +23,7 @@ import { SUPERVISION_ORDER } from '../../supervision-order/models/supervision-or
2223
import { excludeFromEquals } from '../../utilities/equals.decorators';
2324
import { WorkspaceitemSectionsObject } from './workspaceitem-sections.model';
2425

25-
export interface SubmissionObjectError {
26-
message: string;
27-
paths: string[];
28-
}
26+
export type SubmissionObjectError = PathableObjectError;
2927

3028
/**
3129
* An abstract model class for a SubmissionObject.

src/app/core/submission/submission-response-parsing.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export function normalizeSectionData(obj: any, objIndex?: number) {
6363
obj.place || objIndex,
6464
obj.confidence,
6565
obj.otherInformation,
66+
obj.source,
6667
);
6768
} else if (Array.isArray(obj)) {
6869
result = [];

src/app/submission/edit/submission-edit-can-deactivate.service.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
import { Injectable } from '@angular/core';
2-
import {
3-
ActivatedRoute,
4-
Router,
5-
} from '@angular/router';
62
import {
73
combineLatest,
84
Observable,
@@ -21,8 +17,6 @@ interface PendingChangesGuardComponentInterface {
2117
export class SubmissionEditCanDeactivateService implements PendingChangesGuardComponentInterface {
2218

2319
constructor(
24-
private route: ActivatedRoute,
25-
private router: Router,
2620
private submissionService: SubmissionService,
2721
) { }
2822

src/app/submission/form/collection/submission-form-collection.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
id="collectionControlsDropdownMenu"
3535
aria-labelledby="collectionControlsMenuButton">
3636
<ds-collection-dropdown
37+
[entityType]="entityType"
3738
(selectionChange)="onSelect($event)">
3839
</ds-collection-dropdown>
3940
</div>

src/app/submission/form/collection/submission-form-collection.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ export class SubmissionFormCollectionComponent implements OnDestroy, OnChanges,
8080
*/
8181
@Input() collectionModifiable: boolean | null = null;
8282

83+
/**
84+
* The entity type input used to create a new submission
85+
* @type {string}
86+
*/
87+
@Input() entityType: string;
88+
8389
/**
8490
* The submission id
8591
* @type {string}

src/app/submission/form/footer/submission-form-footer.component.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
}
1515
</div>
1616
<div class="text-end d-flex justify-content-end align-items-center flex-sm-row flex-column">
17+
@if ((hasUnsavedModification | async) !== true && (processingSaveStatus | async) !== true && (processingDepositStatus | async) !== true && (submissionIsInvalid | async)) {
18+
<span>
19+
<i class="fas fa-warning"></i> {{'submission.general.info.invalid' | translate}}
20+
</span>
21+
}
1722
@if ((hasUnsavedModification | async) !== true && (processingSaveStatus | async) !== true && (processingDepositStatus | async) !== true) {
1823
<span>
1924
<i class="fas fa-check-circle"></i> {{'submission.general.info.saved' | translate}}
@@ -51,9 +56,9 @@
5156
class="btn"
5257
id="saveForLater"
5358
[attr.data-test]="'save-for-later' | dsBrowserOnly"
54-
[dsBtnDisabled]="(processingSaveStatus | async) || (processingDepositStatus | async)"
59+
[dsBtnDisabled]="((showDepositAndDiscard | async) !== true && (submissionIsInvalid | async)) || (processingSaveStatus | async) || (processingDepositStatus | async)"
5560
(click)="saveLater($event)">
56-
<span><i class="fas fa-save"></i> {{'submission.general.save-later' | translate}}</span>
61+
<span><i class="fas fa-save"></i> {{saveForLaterLabel() | translate}}</span>
5762
</button>
5863
@if ((showDepositAndDiscard | async)) {
5964
<button

src/app/submission/form/footer/submission-form-footer.component.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,15 @@ export class SubmissionFormFooterComponent implements OnChanges {
132132
},
133133
);
134134
}
135+
136+
/**
137+
* Compute the proper label for the save for later button
138+
*/
139+
public saveForLaterLabel(): string {
140+
if (this.submissionService.getSubmissionScope() === SubmissionScopeType.EditItem) {
141+
return 'submission.general.save-later.edit-item';
142+
}
143+
return 'submission.general.save-later';
144+
}
145+
135146
}

src/app/submission/form/submission-form.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<ds-submission-form-collection
1515
[currentCollectionId]="collectionId"
1616
[currentDefinition]="definitionId"
17+
[entityType]="entityType"
1718
[submissionId]="submissionId"
1819
[collectionModifiable]="collectionModifiable"
1920
[isReadonly]="isSectionReadonly"

0 commit comments

Comments
 (0)