Deal specially with has operator #84

This commit is contained in:
Lukas Martinelli 2017-01-15 10:42:59 +01:00
parent a111599850
commit a1e1895651

View file

@ -17,7 +17,13 @@ class SingleFilterEditor extends React.Component {
} }
onFilterPartChanged(filterOp, propertyName, filterArgs) { onFilterPartChanged(filterOp, propertyName, filterArgs) {
const newFilter = [filterOp, propertyName, ...filterArgs] let newFilter = [filterOp, propertyName, ...filterArgs]
console.log('filter changed', filterOp, propertyName, filterArgs)
if(filterOp === 'has' || filterOp === '!has') {
newFilter = [filterOp, propertyName]
} else if(filterArgs.length === 0) {
newFilter = [filterOp, propertyName, '']
}
this.props.onChange(newFilter) this.props.onChange(newFilter)
} }
@ -42,12 +48,14 @@ class SingleFilterEditor extends React.Component {
options={otherFilterOps} options={otherFilterOps}
/> />
</div> </div>
{filterArgs.length > 0 &&
<div className="maputnik-filter-editor-args"> <div className="maputnik-filter-editor-args">
<StringInput <StringInput
value={filterArgs.join(',')} value={filterArgs.join(',')}
onChange={ v=> this.onFilterPartChanged(filterOp, propertyName, v.split(','))} onChange={ v=> this.onFilterPartChanged(filterOp, propertyName, v.split(','))}
/> />
</div> </div>
}
</div> </div>
} }