Skip to content

Commit 3d32715

Browse files
127655: Fixed getFirstDataDefinition not always returning a correct SubmitDataResponseDefinitionObject, leading to an infinite loading screen
- Also fixed an issue where the collection switcher could accidentally show the old collection name instead of the new one - Also updated the WorkspaceItemPageResolver & WorkflowItemPageResolver to embed the collection to use fewer requests
1 parent c1bd65e commit 3d32715

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const getFirstDataDefinition = () =>
3333
if (response.hasFailed) {
3434
throw new Error(response.errorMessage);
3535
} else {
36-
return hasValue(response.payload) ? response.payload.dataDefinition : response.payload;
36+
return hasValue(response?.payload?.dataDefinition) ? response.payload.dataDefinition : [response.payload];
3737
}
3838
}),
3939
distinctUntilChanged(),

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { TestScheduler } from 'rxjs/testing';
2727
import { SectionsService } from '../sections/sections.service';
2828
import { VisibilityType } from '../sections/visibility-type';
2929

30-
describe('SubmissionFormComponent Component', () => {
30+
describe('SubmissionFormComponent', () => {
3131

3232
let comp: SubmissionFormComponent;
3333
let compAsAny: any;
@@ -197,7 +197,6 @@ describe('SubmissionFormComponent Component', () => {
197197
});
198198
scheduler.flush();
199199

200-
expect(comp.collectionId).toEqual(submissionObjectNew.collection.id);
201200
expect(comp.submissionDefinition).toEqual(submissionObjectNew.submissionDefinition);
202201
expect(comp.definitionId).toEqual(submissionObjectNew.submissionDefinition.name);
203202
expect(comp.sections).toEqual(submissionObjectNew.sections);
@@ -235,7 +234,6 @@ describe('SubmissionFormComponent Component', () => {
235234
});
236235
scheduler.flush();
237236

238-
expect(comp.collectionId).toEqual('45f2f3f1-ba1f-4f36-908a-3f1ea9a557eb');
239237
expect(submissionServiceStub.resetSubmissionObject).not.toHaveBeenCalled();
240238
done();
241239
});

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,12 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy {
249249
* new submission object
250250
*/
251251
onCollectionChange(submissionObject: SubmissionObject) {
252-
this.collectionId = (submissionObject.collection as Collection).id;
253252
if (this.definitionId !== (submissionObject.submissionDefinition as SubmissionDefinitionsModel).name) {
254253
this.sections = submissionObject.sections;
255254
this.submissionDefinition = (submissionObject.submissionDefinition as SubmissionDefinitionsModel);
256255
this.definitionId = this.submissionDefinition.name;
257256
this.submissionService.resetSubmissionObject(
258-
this.collectionId,
257+
(submissionObject.collection as Collection).id,
259258
this.submissionId,
260259
submissionObject._links.self.href,
261260
this.submissionDefinition,

src/app/workflowitems-edit-page/workflow-item-page.resolver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class WorkflowItemPageResolver implements Resolve<RemoteData<WorkflowItem
2727
true,
2828
false,
2929
followLink('item'),
30+
followLink('collection'),
3031
).pipe(
3132
getFirstCompletedRemoteData(),
3233
);

src/app/workspaceitems-edit-page/workspace-item-page.resolver.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { Observable } from 'rxjs';
44
import { RemoteData } from '../core/data/remote-data';
55
import { followLink } from '../shared/utils/follow-link-config.model';
66
import { WorkspaceitemDataService } from '../core/submission/workspaceitem-data.service';
7-
import { WorkflowItem } from '../core/submission/models/workflowitem.model';
7+
import { WorkspaceItem } from '../core/submission/models/workspaceitem.model';
88
import { getFirstCompletedRemoteData } from '../core/shared/operators';
99

1010
/**
1111
* This class represents a resolver that requests a specific workflow item before the route is activated
1212
*/
1313
@Injectable()
14-
export class WorkspaceItemPageResolver implements Resolve<RemoteData<WorkflowItem>> {
14+
export class WorkspaceItemPageResolver implements Resolve<RemoteData<WorkspaceItem>> {
1515
constructor(private workspaceItemService: WorkspaceitemDataService) {
1616
}
1717

@@ -22,11 +22,12 @@ export class WorkspaceItemPageResolver implements Resolve<RemoteData<WorkflowIte
2222
* @returns Observable<<RemoteData<Item>> Emits the found workflow item based on the parameters in the current route,
2323
* or an error if something went wrong
2424
*/
25-
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<WorkflowItem>> {
25+
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<WorkspaceItem>> {
2626
return this.workspaceItemService.findById(route.params.id,
2727
true,
2828
false,
2929
followLink('item'),
30+
followLink('collection'),
3031
).pipe(
3132
getFirstCompletedRemoteData(),
3233
);

0 commit comments

Comments
 (0)