From b9480f7407c65415bcdd3ca3ef4be9559bbe03e2 Mon Sep 17 00:00:00 2001 From: Bogdan Cochior <bogdan.cochior@thinslices.com> Date: Thu, 27 Sep 2018 15:58:44 +0300 Subject: [PATCH] fix(mts): fix empty statement for 'yes' selection --- packages/component-mts-package/src/MTS.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/component-mts-package/src/MTS.js b/packages/component-mts-package/src/MTS.js index 5907e433d..22d862896 100644 --- a/packages/component-mts-package/src/MTS.js +++ b/packages/component-mts-package/src/MTS.js @@ -166,6 +166,12 @@ class MTS { ? 'no' : hasDataAvailability + const getQuestionMessage = (selection, message, defaultMessage) => { + if (selection === 'yes') { + return '' + } + return isEmpty(message) ? defaultMessage : message + } if (!isEmpty(hasConflicts)) { questions.push({ _attributes: { @@ -188,9 +194,11 @@ class MTS { _text: capitalize(dataAvailability), }, statement: { - _text: isEmpty(dataAvailabilityMessage) - ? 'The authors for this paper did not provide a data availability statement' - : dataAvailabilityMessage, + _text: getQuestionMessage( + dataAvailability, + dataAvailabilityMessage, + 'The authors for this paper did not provide a data availability statement', + ), }, }) } @@ -203,9 +211,11 @@ class MTS { _text: capitalize(funding), }, statement: { - _text: isEmpty(fundingMessage) - ? 'The authors for this paper did not provide a funding statement' - : fundingMessage, + _text: getQuestionMessage( + funding, + fundingMessage, + 'The authors for this paper did not provide a funding statement', + ), }, }) } -- GitLab