Skip to content

Commit a3c14c5

Browse files
[DURACOM-453] finalize improvement for submission and edit mode
1 parent 1e9fbee commit a3c14c5

26 files changed

Lines changed: 977 additions & 67 deletions

src/app/app-routes.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { ACCESS_CONTROL_MODULE_PATH } from './access-control/access-control-rout
2828
import { NOTIFICATIONS_MODULE_PATH } from './admin/admin-routing-paths';
2929
import {
3030
ADMIN_MODULE_PATH,
31+
EDIT_ITEM_PATH,
3132
FORGOT_PASSWORD_PATH,
3233
HEALTH_PAGE_PATH,
3334
PROFILE_MODULE_PATH,
@@ -279,6 +280,11 @@ export const APP_ROUTES: Route[] = [
279280
.then((m) => m.ROUTES),
280281
canActivate: [authenticatedGuard],
281282
},
283+
{
284+
path: EDIT_ITEM_PATH,
285+
loadChildren: () => import('./edit-item/edit-item-routes').then((m) => m.ROUTES),
286+
canActivate: [endUserAgreementCurrentUserGuard],
287+
},
282288
{
283289
path: 'external-login/:token',
284290
loadChildren: () => import('./external-login-page/external-login-routes').then((m) => m.ROUTES),

src/app/core/data/remote-data.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
isSuccessStale,
1313
RequestEntryState,
1414
} from './request-entry-state.model';
15+
import { PathableObjectError } from './response-state.model';
1516

1617
/**
1718
* A class to represent the state of a remote resource
@@ -25,6 +26,7 @@ export class RemoteData<T> {
2526
public errorMessage?: string,
2627
public payload?: T,
2728
public statusCode?: number,
29+
public errors?: PathableObjectError[],
2830
) {
2931
}
3032

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
import { HALLink } from '../shared/hal-link.model';
22
import { UnCacheableObject } from '../shared/uncacheable-object.model';
33

4+
/**
5+
* Interface for rest error associated to a path
6+
*/
7+
export interface PathableObjectError {
8+
message: string;
9+
paths: string[];
10+
}
11+
412
/**
513
* The response substate in the NgRx store
614
*/
715
export class ResponseState {
816
timeCompleted: number;
917
statusCode: number;
1018
errorMessage?: string;
19+
errors?: PathableObjectError[];
1120
payloadLink?: HALLink;
1221
unCacheableObject?: UnCacheableObject;
1322
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ export interface SubmissionSectionObject {
7575
*/
7676
isLoading: boolean;
7777

78+
/**
79+
* A boolean representing if this section removal is pending
80+
*/
81+
removePending: boolean;
82+
7883
/**
7984
* A boolean representing if this section is valid
8085
*/

src/app/core/submission/submission-rest.service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,15 @@ export class SubmissionRestService {
9191
* The identifier for the object
9292
* @param collectionId
9393
* The owning collection for the object
94+
* @param projections
9495
*/
95-
protected getEndpointByIDHref(endpoint, resourceID, collectionId?: string): string {
96+
protected getEndpointByIDHref(endpoint, resourceID, collectionId?: string, projections: string[] = []): string {
9697
let url = isNotEmpty(resourceID) ? `${endpoint}/${resourceID}` : `${endpoint}`;
9798
url = new URLCombiner(url, '?embed=item,sections,collection').toString();
99+
100+
projections.forEach((projection) => {
101+
url = new URLCombiner(url, '&projection=' + projection).toString();
102+
});
98103
if (collectionId) {
99104
url = new URLCombiner(url, `&owningCollection=${collectionId}`).toString();
100105
}
@@ -135,9 +140,9 @@ export class SubmissionRestService {
135140
* @return Observable<SubmitDataResponseDefinitionObject>
136141
* server response
137142
*/
138-
public getDataById(linkName: string, id: string, useCachedVersionIfAvailable = false): Observable<SubmitDataResponseDefinitionObject> {
143+
public getDataById(linkName: string, id: string, useCachedVersionIfAvailable = false, projections: string[] = []): Observable<SubmitDataResponseDefinitionObject> {
139144
return this.halService.getEndpoint(linkName).pipe(
140-
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, id)),
145+
map((endpointURL: string) => this.getEndpointByIDHref(endpointURL, id, null, projections)),
141146
filter((href: string) => isNotEmpty(href)),
142147
distinctUntilChanged(),
143148
mergeMap((endpointURL: string) => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export enum SubmissionScopeType {
22
WorkspaceItem = 'WORKSPACE',
33
WorkflowItem = 'WORKFLOW',
4+
EditItem = 'EDIT'
45
}

src/app/core/testing/submission-service.stub.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export class SubmissionServiceStub {
2525
isSubmissionLoading = jasmine.createSpy('isSubmissionLoading');
2626
notifyNewSection = jasmine.createSpy('notifyNewSection');
2727
redirectToMyDSpace = jasmine.createSpy('redirectToMyDSpace');
28+
redirectToItemPage = jasmine.createSpy('redirectToItemPage');
2829
resetAllSubmissionObjects = jasmine.createSpy('resetAllSubmissionObjects');
2930
resetSubmissionObject = jasmine.createSpy('resetSubmissionObject');
3031
retrieveSubmission = jasmine.createSpy('retrieveSubmission');

src/app/core/utilities/remote-data.utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66

77
import { RemoteData } from '../data/remote-data';
88
import { RequestEntryState } from '../data/request-entry-state.model';
9+
import { PathableObjectError } from '../data/response-state.model';
910

1011
/**
1112
* A fixed timestamp to use in tests
@@ -45,7 +46,7 @@ export function createSuccessfulRemoteDataObject$<T>(object: T, timeCompleted?:
4546
* @param statusCode the status code
4647
* @param timeCompleted the moment when the remoteData was completed
4748
*/
48-
export function createFailedRemoteDataObject<T>(errorMessage?: string, statusCode?: number, timeCompleted = 1577836800000): RemoteData<T> {
49+
export function createFailedRemoteDataObject<T>(errorMessage?: string, statusCode?: number, timeCompleted = 1577836800000, errors: PathableObjectError[] = []): RemoteData<T> {
4950
return new RemoteData(
5051
timeCompleted,
5152
15 * 60 * 1000,
@@ -54,6 +55,7 @@ export function createFailedRemoteDataObject<T>(errorMessage?: string, statusCod
5455
errorMessage,
5556
undefined,
5657
statusCode,
58+
errors,
5759
);
5860
}
5961

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Route } from '@angular/router';
2+
3+
import { authenticatedGuard } from '../core/auth/authenticated.guard';
4+
import { pendingChangesGuard } from '../submission/edit/pending-changes/pending-changes.guard';
5+
import { ThemedSubmissionEditComponent } from '../submission/edit/themed-submission-edit.component';
6+
7+
export const ROUTES: Route[] = [
8+
{
9+
path: ':id',
10+
runGuardsAndResolvers: 'always',
11+
children: [
12+
{
13+
path: '',
14+
canActivate: [authenticatedGuard],
15+
canDeactivate: [pendingChangesGuard],
16+
component: ThemedSubmissionEditComponent,
17+
data: { title: 'submission.edit.title' },
18+
},
19+
],
20+
},
21+
];

src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
415415

416416
it('should call announceErrorMessages on SAVE_SUBMISSION_FORM_ERROR', () => {
417417
spyOn(component, 'announceErrorMessages');
418-
actions$.next(new SaveSubmissionFormErrorAction('1234'));
418+
actions$.next(new SaveSubmissionFormErrorAction('1234', null, null));
419419
expect(component.announceErrorMessages).toHaveBeenCalled();
420420
});
421421

@@ -427,7 +427,7 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
427427

428428
it('should call announceErrorMessages on SAVE_SUBMISSION_SECTION_FORM_ERROR', () => {
429429
spyOn(component, 'announceErrorMessages');
430-
actions$.next(new SaveSubmissionSectionFormErrorAction('1234'));
430+
actions$.next(new SaveSubmissionSectionFormErrorAction('1234', null, null));
431431
expect(component.announceErrorMessages).toHaveBeenCalled();
432432
});
433433
});

0 commit comments

Comments
 (0)