Skip to content

Commit

Permalink
fix(core/forms): add default choiceorigins to schema when export form…
Browse files Browse the repository at this point in the history
… to pdf
  • Loading branch information
sara-gnucoop committed Jul 22, 2021
1 parent f10d545 commit 8632c9b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/forms/form-to-pdf/form-to-pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,16 @@ function fieldToPdf(
const selectedValues = (field.fieldType === AjfFieldType.SingleChoice) ?
[lookupString(field.name)] :
lookupArrayFunction(context, rep)(field.name);
const selectedChoices =
let selectedChoices =
selectedValues.map(v => choices.find(c => c.value === v)).filter(c => c) as
AjfChoice<any>[];
if (selectedChoices.length === 0) {
selectedChoices =
selectedValues.map(v => ({
label: v,
value: v
} as AjfChoice<string>));
}
return choiceToPdf(field, selectedChoices, translate, context);
case AjfFieldType.Empty:
const text = stripHTML(translate((field as AjfEmptyField).HTML));
Expand Down

0 comments on commit 8632c9b

Please sign in to comment.