Skip to content

Commit

Permalink
Merge pull request #182 from ONSdigital/revert-181-revert-170-ear-194…
Browse files Browse the repository at this point in the history
…8-option-values-for-rd-cb-s

EAR 1948 add option values for rad cb sel answers
  • Loading branch information
farres1 authored Oct 30, 2024
2 parents 14fc1de + 028cb63 commit 95ef225
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ const getOptionValues = (optionIds, questionnaire) => {
const optionResults = optionIds.map((id) => {
const option = find(options, { id });

const updatedLabel = option.label
const optionContent = option.value
? option.value.trim()
: option.label.trim();

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

return updatedLabel.trim();
return updatedContent.trim();
});

if (optionResults === undefined || optionResults.length < 0) {
Expand Down
6 changes: 4 additions & 2 deletions src/eq_schema/schema/Answer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,14 @@ class Answer {
}

static buildOption(
{ label, description, additionalAnswer, qCode: q_code },
{ label, description, additionalAnswer, qCode: q_code, value },
{ properties, type },
ctx
) {
const optionValue = value ? value : label;
const option = {
label: buildContents(label, ctx, true),
value: buildContents(label, ctx, true),
value: buildContents(optionValue, ctx, true),
};

if (q_code) {
Expand All @@ -279,6 +280,7 @@ class Answer {
}
}
}

return option;
}
}
Expand Down

0 comments on commit 95ef225

Please sign in to comment.