2
0

(condition) Add regex comparison item

This commit is contained in:
Baptiste Arnaud
2023-08-01 08:20:16 +02:00
parent 14c3d95b8a
commit aa9f5bc732
6 changed files with 81 additions and 13 deletions

View File

@@ -43,9 +43,33 @@ export const ComparisonItem = ({
<TextInput
defaultValue={item.value ?? ''}
onChange={handleChangeValue}
placeholder="Type a value..."
placeholder={parseValuePlaceholder(item.comparisonOperator)}
/>
)}
</Stack>
)
}
const parseValuePlaceholder = (
operator: ComparisonOperators | undefined
): string => {
switch (operator) {
case ComparisonOperators.NOT_EQUAL:
case ComparisonOperators.EQUAL:
case ComparisonOperators.CONTAINS:
case ComparisonOperators.STARTS_WITH:
case ComparisonOperators.ENDS_WITH:
case ComparisonOperators.NOT_CONTAINS:
case undefined:
return 'Type a value...'
case ComparisonOperators.LESS:
case ComparisonOperators.GREATER:
return 'Type a number...'
case ComparisonOperators.IS_SET:
case ComparisonOperators.IS_EMPTY:
return ''
case ComparisonOperators.MATCHES_REGEX:
case ComparisonOperators.NOT_MATCH_REGEX:
return '^[0-9]+$'
}
}

View File

@@ -74,5 +74,9 @@ const parseComparisonOperatorSymbol = (
return 'is empty'
case ComparisonOperators.NOT_CONTAINS:
return 'not contains'
case ComparisonOperators.MATCHES_REGEX:
return 'matches'
case ComparisonOperators.NOT_MATCH_REGEX:
return 'not matches'
}
}