Skip to content

Commit 10d9b18

Browse files
Fix/gfs schemas (#553)
* fix(moderation): add registration moderation guard * fix(files): file menu updates * fix(files): reset files pagination * fix(files): add provider for create guid * fix(files): files redirect and create guid * fix(gfs): update question rendering
1 parent b3c46cd commit 10d9b18

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/app/features/registries/components/custom-step/custom-step.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ <h2>{{ currentPage().title }}</h2>
1212

1313
@let questions = currentPage().questions || [];
1414

15+
<ng-container *ngTemplateOutlet="questionList; context: { $implicit: questions }"></ng-container>
16+
1517
@if (currentPage().sections?.length) {
1618
@for (section of currentPage().sections; track section.id) {
1719
<p-card>
@@ -29,8 +31,6 @@ <h3 class="mb-2">{{ section.title }}</h3>
2931
<ng-container *ngTemplateOutlet="questionList; context: { $implicit: section.questions }"></ng-container>
3032
</p-card>
3133
}
32-
} @else {
33-
<ng-container *ngTemplateOutlet="questionList; context: { $implicit: questions }"></ng-container>
3434
}
3535

3636
<ng-template #questionList let-questions>

src/app/features/registries/components/custom-step/custom-step.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class CustomStepComponent implements OnDestroy {
118118
this.stepForm = this.fb.group({});
119119
let questions = page.questions || [];
120120
if (page.sections?.length) {
121-
questions = page.sections.flatMap((section) => section.questions || []);
121+
questions = [...questions, ...page.sections.flatMap((section) => section.questions ?? [])];
122122
}
123123
questions?.forEach((q) => {
124124
const controlName = q.responseKey as string;

src/app/features/registries/components/drafts/drafts.component.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ActivatedRoute, NavigationEnd, Router, RouterOutlet } from '@angular/ro
2020

2121
import { StepperComponent, SubHeaderComponent } from '@osf/shared/components';
2222
import { ResourceType } from '@osf/shared/enums';
23-
import { StepOption } from '@osf/shared/models';
23+
import { PageSchema, Question, StepOption } from '@osf/shared/models';
2424
import { LoaderService } from '@osf/shared/services';
2525
import {
2626
ContributorsSelectors,
@@ -95,8 +95,9 @@ export class DraftsComponent implements OnDestroy {
9595
this.defaultSteps[0].touched = true;
9696
const customSteps = this.pages().map((page, index) => {
9797
const pageStep = this.pages()[index];
98+
const allQuestions = this.getAllQuestions(pageStep);
9899
const wasTouched =
99-
pageStep?.questions?.some((question) => {
100+
allQuestions?.some((question) => {
100101
const questionData = stepData[question.responseKey!];
101102
return Array.isArray(questionData) ? questionData.length : questionData;
102103
}) || false;
@@ -184,8 +185,9 @@ export class DraftsComponent implements OnDestroy {
184185
if (this.pages().length && this.currentStepIndex() > 0 && this.stepsData()) {
185186
for (let i = 1; i < this.currentStepIndex(); i++) {
186187
const pageStep = this.pages()[i - 1];
188+
const allQuestions = this.getAllQuestions(pageStep);
187189
const isStepInvalid =
188-
pageStep?.questions?.some((question) => {
190+
allQuestions?.some((question) => {
189191
const questionData = this.stepsData()[question.responseKey!];
190192
return question.required && (Array.isArray(questionData) ? !questionData.length : !questionData);
191193
}) || false;
@@ -201,6 +203,13 @@ export class DraftsComponent implements OnDestroy {
201203
this.router.navigate([`/registries/drafts/${this.registrationId}/`, pageLink]);
202204
}
203205

206+
private getAllQuestions(pageStep: PageSchema): Question[] {
207+
return [
208+
...(pageStep?.questions ?? []),
209+
...(pageStep?.sections?.flatMap((section) => section.questions ?? []) ?? []),
210+
];
211+
}
212+
204213
ngOnDestroy(): void {
205214
this.actions.clearState();
206215
}

0 commit comments

Comments
 (0)