Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#10488: 'ilike' as default operator for text field in attribute table quick filter #10496

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -38,7 +38,7 @@ class AttributeFilter extends React.PureComponent {
onChange: () => {},
column: {},
placeholderMsgId: "featuregrid.filter.placeholders.default",
operator: "=",
defaultOperator: "=",
isWithinAttrTbl: false
};
constructor(props) {
Expand All @@ -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
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand All @@ -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 });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} = {}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(<StringFilter value={"TEST"} type="string" isWithinAttrTbl />, 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: () => {}
Expand Down
Loading