diff --git a/web/client/components/data/featuregrid/filterRenderers/AttributeFilter.jsx b/web/client/components/data/featuregrid/filterRenderers/AttributeFilter.jsx index b2149bc8a6..bedcf9c657 100644 --- a/web/client/components/data/featuregrid/filterRenderers/AttributeFilter.jsx +++ b/web/client/components/data/featuregrid/filterRenderers/AttributeFilter.jsx @@ -23,7 +23,7 @@ class AttributeFilter extends React.PureComponent { column: PropTypes.object, placeholderMsgId: PropTypes.string, tooltipMsgId: PropTypes.string, - operator: PropTypes.string, + defaultOperator: PropTypes.string, type: PropTypes.string, isWithinAttrTbl: PropTypes.bool }; @@ -38,7 +38,7 @@ class AttributeFilter extends React.PureComponent { onChange: () => {}, column: {}, placeholderMsgId: "featuregrid.filter.placeholders.default", - operator: "=", + defaultOperator: "=", isWithinAttrTbl: false }; constructor(props) { @@ -50,7 +50,7 @@ class AttributeFilter extends React.PureComponent { booleanOperators: ["="], defaultOperators: ["=", ">", "<", ">=", "<=", "<>", "isNull"], timeDateOperators: ["=", ">", "<", ">=", "<=", "<>", "><", "isNull"], - operator: this.props.isWithinAttrTbl ? "=" : "", + operator: this.props.isWithinAttrTbl ? (this.props.defaultOperator) : "", isInputValid: true }; } diff --git a/web/client/components/data/featuregrid/filterRenderers/BaseDateTimeFilter.js b/web/client/components/data/featuregrid/filterRenderers/BaseDateTimeFilter.js index 1e04116388..dc2a97aeba 100644 --- a/web/client/components/data/featuregrid/filterRenderers/BaseDateTimeFilter.js +++ b/web/client/components/data/featuregrid/filterRenderers/BaseDateTimeFilter.js @@ -104,7 +104,7 @@ export class DateFilter extends AttributeFilter { />); } handleChange = (value, stringValue) => { - this.props.onChange({ value, stringValue, attribute: this.props.column && this.props.column.name, inputOperator: this.state.operator || this.props.operator }); + this.props.onChange({ value, stringValue, attribute: this.props.column && this.props.column.name, inputOperator: this.state.operator }); } handleChangeRangeFilter = (value, stringValue, order = 'start') => { let reqVal = {}; @@ -119,7 +119,7 @@ export class DateFilter extends AttributeFilter { endDate: this.props.value?.endDate }; } - this.props.onChange({ value: reqVal, stringValue, attribute: this.props.column && this.props.column.name, inputOperator: this.state.operator || this.props.operator }); + this.props.onChange({ value: reqVal, stringValue, attribute: this.props.column && this.props.column.name, inputOperator: this.state.operator }); } } diff --git a/web/client/components/data/featuregrid/filterRenderers/StringFilter.jsx b/web/client/components/data/featuregrid/filterRenderers/StringFilter.jsx index adb13f44e3..2ea18a3038 100644 --- a/web/client/components/data/featuregrid/filterRenderers/StringFilter.jsx +++ b/web/client/components/data/featuregrid/filterRenderers/StringFilter.jsx @@ -5,7 +5,8 @@ import { trim } from 'lodash'; export default compose( defaultProps({ onValueChange: () => {}, - placeholderMsgId: "featuregrid.filter.placeholders.string" + placeholderMsgId: "featuregrid.filter.placeholders.string", + defaultOperator: 'ilike' }), withHandlers({ onChange: props => ({value, attribute, inputOperator} = {}) => { diff --git a/web/client/components/data/featuregrid/filterRenderers/__tests__/StringFilter-test.jsx b/web/client/components/data/featuregrid/filterRenderers/__tests__/StringFilter-test.jsx index 2f9bf53922..c9da5b6256 100644 --- a/web/client/components/data/featuregrid/filterRenderers/__tests__/StringFilter-test.jsx +++ b/web/client/components/data/featuregrid/filterRenderers/__tests__/StringFilter-test.jsx @@ -35,6 +35,15 @@ describe('Test for StringFilter component', () => { expect(el).toExist(); expect(el.value).toBe("TEST"); }); + it('test the text field with the ilike default operator in attribute table', () => { + ReactDOM.render(, document.getElementById("container")); + const el = document.getElementsByClassName("form-control input-sm")[0]; + expect(el).toExist(); + expect(el.value).toBe("TEST"); + const operatorEl = document.querySelector('.rw-input'); + expect(operatorEl).toExist(); + expect(operatorEl.innerHTML).toEqual("ilike"); + }); it('Test StringFilter onChange', () => { const actions = { onChange: () => {}