Skip to content

Commit

Permalink
🐛 Fix #232 has filter
Browse files Browse the repository at this point in the history
  • Loading branch information
divyanshu013 committed Sep 14, 2018
1 parent 17c5302 commit 23fdcd8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion live/src/js/table/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class Column extends React.Component {
</span>;
const filterRow = this.props.externalQueryApplied ? '' : (
<span className="filterIcon">
<FilterDropdown columnField={item} type={type} datatype={datatype} analyzed={analyzed} filterInfo={this.props.filterInfo} />
<FilterDropdown mappingObj={this.props.mappingObj} columnField={item} type={type} datatype={datatype} analyzed={analyzed} filterInfo={this.props.filterInfo} />
</span>
);
// const handleSort = this.sortingInit;
Expand Down
17 changes: 16 additions & 1 deletion live/src/js/table/FilterDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,23 @@ class FilterDropdown extends React.Component {
};

applyFilter = () => {
const { mappingObj, type, datatype } = this.props;
const mappingFields = mappingObj[type].properties;
if (this.state.filterField != null && this.state.filterValue != null && this.state.filterValue != '') {
this.props.filterInfo.applyFilter(this.props.type, this.props.columnField, this.state.filterField, this.state.filterValue, this.state.filterField === 'has' || this.state.filterField === 'has not' ? false : this.props.analyzed);
let colField = this.props.columnField;
if (datatype === 'string' || datatype === 'keyword' || datatype === 'text') {
const currentMapping = mappingFields[colField];
if (currentMapping.index !== 'not_analyzed') {
const currentFields = currentMapping.fields;
if (currentFields) {
const suffix = Object.keys(currentFields).find(key => currentFields[key].type === 'keyword' || currentFields[key].index === 'not_analyzed');
if (suffix) {
colField += `.${suffix}`;
}
}
}
}
this.props.filterInfo.applyFilter(this.props.type, colField, this.state.filterField, this.state.filterValue, this.state.filterField === 'has' || this.state.filterField === 'has not' ? false : this.props.analyzed);
document.body.click();
}
};
Expand Down

0 comments on commit 23fdcd8

Please sign in to comment.