From b228410eec75a8055021200f2592459924de8b58 Mon Sep 17 00:00:00 2001 From: Kasper Baun Date: Tue, 27 Feb 2024 11:22:08 +0100 Subject: [PATCH] fix: corrected false questionModel.answered condition from payload that evaluated to truthy when payload was undefined --- .../defaults/DefaultQuestionTransformer.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/src/services/defaults/DefaultQuestionTransformer.ts b/packages/core/src/services/defaults/DefaultQuestionTransformer.ts index 842dd8e..6c434de 100644 --- a/packages/core/src/services/defaults/DefaultQuestionTransformer.ts +++ b/packages/core/src/services/defaults/DefaultQuestionTransformer.ts @@ -7,10 +7,10 @@ function mapJsonQuestionToModelQuestion(key: string, question: QuestionJsonModel const parseInputProperties = resolveQuickFormService("inputTypePropertiesTransformer"); const logger = resolveQuickFormService("logger"); - + if (question.inputType === "dropdown" && question.dataType === "boolean") - value = value === true ? 'Y' : value===false? 'N':''; + value = value === true ? 'Y' : value === false ? 'N' : ''; logger.log("Transforming Question {key}: {@question} with value {@value}", key, question, value); @@ -18,13 +18,13 @@ function mapJsonQuestionToModelQuestion(key: string, question: QuestionJsonModel return { logicalName: question.logicalName ?? key, inputType: question.inputType, - dataType: question.dataType??"string", + dataType: question.dataType ?? "string", text: question.text, - placeholder: question.placeholder??'', + placeholder: question.placeholder ?? '', paragraph: question.paragraph, - answered: typeof (value) !== undefined && value !== '', - inputProperties: parseInputProperties(question), - output: value ?? '', + answered: typeof (value) !== "undefined" && value !== '' && value !== null && value !== "", + inputProperties: parseInputProperties(question), + output: value ?? '', } as QuestionModel; } registerQuickFormService("questionTransformer", mapJsonQuestionToModelQuestion); \ No newline at end of file