[explore] improved filters (#2330)

* Support more filter operators

* more filter operators [>, <, >=, <=, ==, !=, LIKE]
* Fix need to escape/double `%` in LIKE clauses
* spinner while loading values when changing column
* datasource config elements to allow to applying predicates when
  fetching filter values
* refactor

* Removing doubling parens

* rebasing

* Merging migrations
This commit is contained in:
Maxime Beauchemin
2017-03-20 21:10:59 -07:00
committed by GitHub
parent 82bc907088
commit 8042ac876e
15 changed files with 245 additions and 243 deletions

View File

@@ -17,6 +17,7 @@ const defaultProps = {
id: 1,
type: 'table',
filter_select: false,
filterable_cols: ['country_name'],
},
};

View File

@@ -10,11 +10,8 @@ import Filter from '../../../../javascripts/explorev2/components/controls/Filter
import SelectControl from '../../../../javascripts/explorev2/components/controls/SelectControl';
const defaultProps = {
choices: ['country_name'],
changeFilter: sinon.spy(),
removeFilter: () => {
// noop
},
removeFilter: () => {},
filter: {
col: null,
op: 'in',
@@ -22,8 +19,9 @@ const defaultProps = {
},
datasource: {
id: 1,
type: 'table',
type: 'qtable',
filter_select: false,
filterable_cols: ['col1', 'col2'],
},
};
@@ -44,7 +42,7 @@ describe('Filter', () => {
expect(wrapper.find(Select)).to.have.lengthOf(2);
expect(wrapper.find(Button)).to.have.lengthOf(1);
expect(wrapper.find(SelectControl)).to.have.lengthOf(1);
expect(wrapper.find('#select-op').prop('options')).to.have.lengthOf(2);
expect(wrapper.find('#select-op').prop('options')).to.have.lengthOf(8);
});
it('renders five op choices for table datasource', () => {
@@ -53,16 +51,17 @@ describe('Filter', () => {
id: 1,
type: 'druid',
filter_select: false,
filterable_cols: ['country_name'],
};
const druidWrapper = shallow(<Filter {...props} />);
expect(druidWrapper.find('#select-op').prop('options')).to.have.lengthOf(5);
expect(druidWrapper.find('#select-op').prop('options')).to.have.lengthOf(9);
});
it('renders six op choices for having filter', () => {
const props = defaultProps;
props.having = true;
const havingWrapper = shallow(<Filter {...props} />);
expect(havingWrapper.find('#select-op').prop('options')).to.have.lengthOf(6);
expect(havingWrapper.find('#select-op').prop('options')).to.have.lengthOf(9);
});
it('calls changeFilter when select is changed', () => {