mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
Add support for case for IN and NOT_IN operators (#2924)
Signed-off-by: andreas-unleash <andreas@getunleash.ai> Adds support for case for IN and NOT_IN operators <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> <img width="1547" alt="Screenshot 2023-01-18 at 11 35 10" src="https://user-images.githubusercontent.com/104830839/213136158-25c525c8-de82-423b-93d1-5ae6eb8469fa.png"> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
parent
89163b8719
commit
91e20cc09a
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user