From 91e20cc09abad339da5a5d511566c4f8ddc8adc1 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Wed, 18 Jan 2023 14:42:26 +0200 Subject: [PATCH] Add support for case for IN and NOT_IN operators (#2924) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: andreas-unleash Adds support for case for IN and NOT_IN operators ## About the changes Closes # ### Important files Screenshot 2023-01-18 at 11 35 10 ## Discussion points Signed-off-by: andreas-unleash --- .../ConstraintAccordionEditHeader.tsx | 3 ++- src/lib/util/feature-evaluator/constraint.ts | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditHeader/ConstraintAccordionEditHeader.tsx b/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditHeader/ConstraintAccordionEditHeader.tsx index 76d6b37519..b4688363ef 100644 --- a/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditHeader/ConstraintAccordionEditHeader.tsx +++ b/frontend/src/component/common/ConstraintAccordion/ConstraintAccordionEdit/ConstraintAccordionEditHeader/ConstraintAccordionEditHeader.tsx @@ -9,6 +9,7 @@ import { DATE_AFTER, IN, stringOperators, + inOperators, } from 'constants/operators'; import { resolveText } from './helpers'; import { oneOf } from 'utils/oneOf'; @@ -123,7 +124,7 @@ export const ConstraintAccordionEditHeader = ({ setOperator(IN); } - if (oneOf(stringOperators, operator)) { + if (oneOf([...stringOperators, ...inOperators], operator)) { setShowCaseSensitiveButton(true); } else { setShowCaseSensitiveButton(false); diff --git a/src/lib/util/feature-evaluator/constraint.ts b/src/lib/util/feature-evaluator/constraint.ts index 72c7c3976b..c39cf17fe5 100644 --- a/src/lib/util/feature-evaluator/constraint.ts +++ b/src/lib/util/feature-evaluator/constraint.ts @@ -39,10 +39,15 @@ const cleanValues = (values: string[]) => const InOperator = (constraint: Constraint, context: Context) => { const field = constraint.contextName; + const caseInsensitive = Boolean(constraint.caseInsensitive); const values = cleanValues(constraint.values); const contextValue = resolveContextValue(context, field); - const isIn = values.some((val) => val === contextValue); + const isIn = values.some((val) => + caseInsensitive + ? val.toLowerCase() === contextValue?.toLowerCase() + : val === contextValue, + ); return constraint.operator === Operator.IN ? isIn : !isIn; };