Skip to content

Commit 5297af1

Browse files
jekabs-karklinsjekabskarklins
andauthored
refactor: return template id for question template relationship object (#1611)
Co-authored-by: jekabskarklins <jekabs.karklins@ess.eu>
1 parent 72be3c2 commit 5297af1

8 files changed

Lines changed: 12 additions & 7 deletions

File tree

apps/backend/src/datasources/mockups/QuestionaryDataSource.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { DeepPartial } from './ProposalDataSource';
12
import {
23
DependenciesLogicOperator,
34
EvaluatorOperator,
@@ -29,7 +30,6 @@ import {
2930
TextInputConfig,
3031
} from '../../resolvers/types/FieldConfig';
3132
import { QuestionaryDataSource } from '../QuestionaryDataSource';
32-
import { DeepPartial } from './ProposalDataSource';
3333

3434
export let dummyQuestionarySteps: QuestionaryStep[];
3535
export let dummyQuestionary: Questionary;
@@ -74,6 +74,7 @@ export const dummyQuestionTemplateRelationFactory = (
7474
dummyQuestionFactory(values?.question),
7575
values?.sortOrder || Math.round(Math.random() * 100),
7676
values?.topicId || Math.round(Math.random() * 10),
77+
values?.templateId || Math.round(Math.random() * 100),
7778
values?.config || { ...new BooleanConfig(), readPermissions: [] },
7879
values?.dependencies as FieldDependency[],
7980
values?.dependenciesOperator as DependenciesLogicOperator

apps/backend/src/datasources/postgres/records.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ export const createQuestionTemplateRelationObject = async <T extends DataType>(
931931
),
932932
record.topic_id,
933933
record.sort_order,
934+
record.template_id,
934935
createConfig<any>(record.data_type as DataType, transformedConfig),
935936
dependencies,
936937
record.dependencies_operator

apps/backend/src/models/Questionary.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class Answer extends QuestionTemplateRelation {
2020
questionTemplateRelation.question,
2121
questionTemplateRelation.topicId,
2222
questionTemplateRelation.sortOrder,
23+
questionTemplateRelation.templateId,
2324
questionTemplateRelation.config,
2425
questionTemplateRelation.dependencies,
2526
questionTemplateRelation.dependenciesOperator

apps/backend/src/models/Template.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export class QuestionTemplateRelation {
8080
public question: Question,
8181
public topicId: number,
8282
public sortOrder: number,
83+
public templateId: number,
8384
public config: typeof FieldConfigType,
8485
public dependencies: FieldDependency[],
8586
public dependenciesOperator?: DependenciesLogicOperator

apps/backend/src/resolvers/types/QuestionTemplateRelation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export class QuestionTemplateRelation
1616
@Field(() => Int)
1717
public sortOrder: number;
1818

19+
@Field(() => Int)
20+
public templateId: number;
21+
1922
@Field(() => Int)
2023
public topicId: number;
2124

apps/frontend/src/components/common/proposalFilters/QuestionaryFilter.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ const extractSearchableQuestions = (
6363
); // only searchable questions
6464
};
6565

66-
function QuestionaryFilter({
67-
onSubmit,
68-
callId,
69-
templateId,
70-
}: QuestionaryFilterProps) {
66+
function QuestionaryFilter({ onSubmit, callId }: QuestionaryFilterProps) {
7167
const { loading: isLoadingQuestionarySteps, questionarySteps } =
7268
useBlankQuestionaryStepsDataByCallId(callId);
7369

@@ -163,7 +159,7 @@ function QuestionaryFilter({
163159
}}
164160
questionTemplateRelation={selectedQuestion}
165161
callId={callId}
166-
templateId={templateId}
162+
templateId={selectedQuestion.templateId}
167163
/>
168164
)}
169165
</Collapse>

apps/frontend/src/graphql/questionary/fragment.answer.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ fragment answer on Answer {
44
...question
55
}
66
sortOrder
7+
templateId
78
topicId
89
config {
910
...fieldConfig

apps/frontend/src/graphql/template/fragment.questionRel.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ fragment questionTemplateRelation on QuestionTemplateRelation {
33
...question
44
}
55
sortOrder
6+
templateId
67
topicId
78
config {
89
...fieldConfig

0 commit comments

Comments
 (0)