diff --git a/src/QueryBuilder/QueryBuilder/helpers/selectOptions.js b/src/QueryBuilder/QueryBuilder/helpers/selectOptions.js index 11e8a960..0dccb4ca 100644 --- a/src/QueryBuilder/QueryBuilder/helpers/selectOptions.js +++ b/src/QueryBuilder/QueryBuilder/helpers/selectOptions.js @@ -36,6 +36,14 @@ const ArrayOperators = () => [ { label: OPERATORS_LABELS.EMPTY, value: OPERATORS.EMPTY }, ]; +const JsonbArrayOperators = () => [ + { label: OPERATORS_LABELS.CONTAINS_ALL, value: OPERATORS.CONTAINS_ALL }, + { label: OPERATORS_LABELS.NOT_CONTAINS_ALL, value: OPERATORS.NOT_CONTAINS_ALL }, + { label: OPERATORS_LABELS.CONTAINS_ANY, value: OPERATORS.CONTAINS_ANY }, + { label: OPERATORS_LABELS.NOT_CONTAINS_ANY, value: OPERATORS.NOT_CONTAINS_ANY }, + { label: OPERATORS_LABELS.EMPTY, value: OPERATORS.EMPTY }, +]; + const UUIDOperators = () => [ { label: OPERATORS_LABELS.EQUAL, value: OPERATORS.EQUAL }, { label: OPERATORS_LABELS.IN, value: OPERATORS.IN }, @@ -89,6 +97,9 @@ export const getOperatorOptions = ({ case DATA_TYPES.ArrayType: return getOperatorsWithPlaceholder(ArrayOperators(), intl); + case DATA_TYPES.JsonbArrayType: + return getOperatorsWithPlaceholder(JsonbArrayOperators(), intl); + case DATA_TYPES.DateType: return getOperatorsWithPlaceholder(extendedLogicalOperators(), intl); diff --git a/src/QueryBuilder/QueryBuilder/helpers/selectOptions.test.js b/src/QueryBuilder/QueryBuilder/helpers/selectOptions.test.js index e356623e..2cdabbb3 100644 --- a/src/QueryBuilder/QueryBuilder/helpers/selectOptions.test.js +++ b/src/QueryBuilder/QueryBuilder/helpers/selectOptions.test.js @@ -241,6 +241,25 @@ describe('select options', () => { }); }); + it('should return operators with placeholder for jsonb array type', () => { + const options = getOperatorOptions({ + dataType: DATA_TYPES.JsonbArrayType, + hasSourceOrValues: false, + intl: intlMock, + }); + + expectFn({ + options, + operators: [ + { label: OPERATORS_LABELS.CONTAINS_ALL, value: OPERATORS.CONTAINS_ALL }, + { label: OPERATORS_LABELS.NOT_CONTAINS_ALL, value: OPERATORS.NOT_CONTAINS_ALL }, + { label: OPERATORS_LABELS.CONTAINS_ANY, value: OPERATORS.CONTAINS_ANY }, + { label: OPERATORS_LABELS.NOT_CONTAINS_ANY, value: OPERATORS.NOT_CONTAINS_ANY }, + { label: OPERATORS_LABELS.EMPTY, value: OPERATORS.EMPTY }, + ], + }); + }); + it('should return operators with placeholder for enum type', () => { const options = getOperatorOptions({ dataType: DATA_TYPES.EnumType, diff --git a/src/constants/dataTypes.js b/src/constants/dataTypes.js index d4f422fc..0a74dcce 100644 --- a/src/constants/dataTypes.js +++ b/src/constants/dataTypes.js @@ -10,4 +10,5 @@ export const DATA_TYPES = { EnumType: 'enumType', ObjectType: 'objectType', ArrayType: 'arrayType', + JsonbArrayType: 'jsonbArrayType', };