Skip to content

Commit f5d496a

Browse files
authored
Merge pull request #221 from ONSdigital/fix-option-values-data-version
Fix option values for data versions
2 parents 95ef225 + f931acf commit f5d496a

File tree

2 files changed

+6
-4
lines changed
  • src/eq_schema

2 files changed

+6
-4
lines changed

src/eq_schema/builders/routing2/newRoutingDestination/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ const getOptionValues = (optionIds, questionnaire) => {
2727
const optionResults = optionIds.map((id) => {
2828
const option = find(options, { id });
2929

30-
const optionContent = option.value
31-
? option.value.trim()
32-
: option.label.trim();
30+
const optionContent =
31+
questionnaire.dataVersion === "3" && option.value
32+
? option.value.trim()
33+
: option.label.trim();
3334

3435
const updatedContent = optionContent
3536
.replace(/'/g, `\u2019`)

src/eq_schema/schema/Answer/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ class Answer {
252252
{ properties, type },
253253
ctx
254254
) {
255-
const optionValue = value ? value : label;
255+
const optionValue =
256+
ctx && ctx.questionnaireJson.dataVersion === "3" && value ? value : label;
256257
const option = {
257258
label: buildContents(label, ctx, true),
258259
value: buildContents(optionValue, ctx, true),

0 commit comments

Comments
 (0)