Skip to content

Commit

Permalink
correcting shameful bugs introduced by lack of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheus Silva Santos committed Mar 25, 2019
1 parent 68bf3d8 commit 69d1392
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions components/ui/FilterModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ class FilterModal extends Component {
return
}

this.setState({ query, invalidJsonAlertVisible: false }, () =>
this.setState({ query, invalidJsonAlertVisible: false }, () => {
console.debug('calling back onFilterChange with filter', query)
this.props.onFilterChange(this.state.query)
)
})
}

createSimpleFilter = () => {
Expand All @@ -81,14 +82,15 @@ class FilterModal extends Component {
return `(${qs.join(' OR ')})`
}
)
return fields.length > 1 ? compile(fields.join(' AND ')) : {}
return fields.length > 0 ? compile(fields.join(' AND ')) : {}
}

createAdvancedFilter = () => {
let query = JSON.parse(this.state.advancedFormValue)
// the query param does not support
// anything but an obj in root level
if (Array.isArray(query) || !(query instanceof Object)) throw SyntaxError
return query
}

handleSimpleFormChange = (key, value) => {
Expand Down

0 comments on commit 69d1392

Please sign in to comment.