-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added filter in ControlPanelsContainer for explore V2 (#1647)
* Added filter in ControlPanelsContainer * Move function for getting url params object to utils * Fixed python test * Move Filter to separate component * Added specs and made changes based on comments * Moved specs to right folder
- Loading branch information
Showing
15 changed files
with
354 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
superset/assets/javascripts/explorev2/components/Filter.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React from 'react'; | ||
// import { Tab, Row, Col, Nav, NavItem } from 'react-bootstrap'; | ||
import Select from 'react-select'; | ||
import { Button } from 'react-bootstrap'; | ||
|
||
const propTypes = { | ||
actions: React.PropTypes.object.isRequired, | ||
filterColumnOpts: React.PropTypes.array, | ||
prefix: React.PropTypes.string, | ||
filter: React.PropTypes.object.isRequired, | ||
}; | ||
|
||
const defaultProps = { | ||
filterColumnOpts: [], | ||
prefix: 'flt', | ||
}; | ||
|
||
export default class Filter extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
const opChoices = this.props.prefix === 'flt' ? | ||
['in', 'not in'] : ['==', '!=', '>', '<', '>=', '<=']; | ||
this.state = { | ||
opChoices, | ||
}; | ||
} | ||
changeCol(filter, colOpt) { | ||
const val = (colOpt) ? colOpt.value : null; | ||
this.props.actions.changeFilter(filter, 'col', val); | ||
} | ||
changeOp(filter, opOpt) { | ||
const val = (opOpt) ? opOpt.value : null; | ||
this.props.actions.changeFilter(filter, 'op', val); | ||
} | ||
changeValue(filter, event) { | ||
this.props.actions.changeFilter(filter, 'value', event.target.value); | ||
} | ||
removeFilter(filter) { | ||
this.props.actions.removeFilter(filter); | ||
} | ||
render() { | ||
return ( | ||
<div> | ||
<div className="row space-1"> | ||
<Select | ||
className="col-lg-12" | ||
multi={false} | ||
name="select-column" | ||
placeholder="Select column" | ||
options={this.props.filterColumnOpts.map((o) => ({ value: o, label: o }))} | ||
value={this.props.filter.col} | ||
autosize={false} | ||
onChange={this.changeCol.bind(this, this.props.filter)} | ||
/> | ||
</div> | ||
<div className="row space-1"> | ||
<Select | ||
className="col-lg-4" | ||
multi={false} | ||
name="select-op" | ||
placeholder="Select operator" | ||
options={this.state.opChoices.map((o) => ({ value: o, label: o }))} | ||
value={this.props.filter.op} | ||
autosize={false} | ||
onChange={this.changeOp.bind(this, this.props.filter)} | ||
/> | ||
<div className="col-lg-6"> | ||
<input | ||
type="text" | ||
onChange={this.changeValue.bind(this, this.props.filter)} | ||
value={this.props.filter.value} | ||
className="form-control input-sm" | ||
placeholder="Filter value" | ||
/> | ||
</div> | ||
<div className="col-lg-2"> | ||
<Button | ||
id="remove-button" | ||
bsSize="small" | ||
onClick={this.removeFilter.bind(this, this.props.filter)} | ||
> | ||
<i className="fa fa-minus" /> | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Filter.propTypes = propTypes; | ||
Filter.defaultProps = defaultProps; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.