diff --git a/src/components/Drawer/Drawer.css b/src/components/Drawer/Drawer.css index ed8cc1d..f535b0f 100644 --- a/src/components/Drawer/Drawer.css +++ b/src/components/Drawer/Drawer.css @@ -1,6 +1,6 @@ .drawer { display: block; - height: 100%; + height: calc(100% - 64px); background: white; position: fixed; top: 64px; diff --git a/src/components/EnableWhen/EnableBehavior.tsx b/src/components/EnableWhen/EnableBehavior.tsx index c37c22c..af8d7be 100644 --- a/src/components/EnableWhen/EnableBehavior.tsx +++ b/src/components/EnableWhen/EnableBehavior.tsx @@ -21,16 +21,13 @@ const EnableBehavior = ({ currentItem, dispatchUpdateItemEnableBehavior }: Props ? QuestionnaireItemEnableBehaviorCodes.ALL : QuestionnaireItemEnableBehaviorCodes.ANY } - options={[ - { - code: QuestionnaireItemEnableBehaviorCodes.ANY, - display: t('At least one condition must be fulfilled'), - }, - { - code: QuestionnaireItemEnableBehaviorCodes.ALL, - display: t('All conditions must be fulfilled'), - }, - ]} + options={[{ + code: QuestionnaireItemEnableBehaviorCodes.ALL, + display: t('All conditions must be fulfilled') + }, { + code: QuestionnaireItemEnableBehaviorCodes.ANY, + display: t('At least one condition must be fulfilled') + }]} name={`ew-behavior-${currentItem.linkId}`} /> diff --git a/src/components/EnableWhen/EnableWhen.tsx b/src/components/EnableWhen/EnableWhen.tsx index e2fe47b..96c7c1f 100644 --- a/src/components/EnableWhen/EnableWhen.tsx +++ b/src/components/EnableWhen/EnableWhen.tsx @@ -64,7 +64,13 @@ const EnableWhen = ({ return (
-

{t('Set a condition for displaying this question:')}

+

{t('Define which conditions must be fulfilled for enabling this question.\nIf no conditions are defined, the question is always enabled.')}

+ {enableWhen.length > 1 && ( + + )} {enableWhen.map((x, index) => { const conditionItem = getItem(x.question); const hasValidationError = itemValidationErrors.some( @@ -158,12 +164,6 @@ const EnableWhen = ({ icon="ion-plus-round" title={t('Add a condition')} /> - {enableWhen.length > 1 && ( - - )} {enableWhen.length > 0 && ( (val: T | undefined, ...options: (T | undefined)[]): boolean => { + return options.includes(val); + }; + + if (action.itemProperty === 'enableWhen') { + const numEntries = (action.itemValue as IEnableWhen[]).length; + if (numEntries <= 1) { + draft.qItems[action.linkId].enableBehavior = undefined; + } else if (numEntries > 1 && + !isAnyOf(draft.qItems[action.linkId].enableBehavior, QuestionnaireItemEnableBehaviorCodes.ALL, QuestionnaireItemEnableBehaviorCodes.ANY) + ) { + draft.qItems[action.linkId].enableBehavior = QuestionnaireItemEnableBehaviorCodes.ALL; + } + } } function addItemCode(draft: TreeState, action: AddItemCodeAction): void {