Add filter item

This commit is contained in:
Lukas Martinelli 2017-01-09 16:33:26 +01:00
parent 5bb68a38c2
commit ed9b806143

View file

@ -35,6 +35,7 @@ class CombiningOperatorSelect extends React.Component {
static propTypes = { static propTypes = {
value: React.PropTypes.string.isRequired, value: React.PropTypes.string.isRequired,
onChange: React.PropTypes.func.isRequired, onChange: React.PropTypes.func.isRequired,
style: React.PropTypes.object,
} }
render() { render() {
@ -46,6 +47,7 @@ class CombiningOperatorSelect extends React.Component {
style={{ style={{
marginTop: margins[1], marginTop: margins[1],
marginBottom: margins[1], marginBottom: margins[1],
...this.props.style
}} }}
> >
<select <select
@ -176,6 +178,12 @@ export default class CombiningFilterEditor extends React.Component {
this.props.onChange(newFilter) this.props.onChange(newFilter)
} }
addFilterItem() {
const newFilterItem = this.combiningFilter().slice(0)
newFilterItem.push(['==', 'name', ''])
this.props.onChange(newFilterItem)
}
render() { render() {
const filter = this.combiningFilter() const filter = this.combiningFilter()
let combiningOp = filter[0] let combiningOp = filter[0]
@ -211,7 +219,12 @@ export default class CombiningFilterEditor extends React.Component {
<CombiningOperatorSelect <CombiningOperatorSelect
value={combiningOp} value={combiningOp}
onChange={this.onFilterPartChanged.bind(this, 0)} onChange={this.onFilterPartChanged.bind(this, 0)}
style={{
display: 'inline-block',
width: '80%'
}}
/> />
<Button onClick={this.addFilterItem.bind(this)}>Add filter</Button>
{filterEditors} {filterEditors}
</div> </div>
} }