mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 17:41:16 +01:00
Convert filter value to number if possible #63
This commit is contained in:
parent
a1e1895651
commit
05349d8ffe
1 changed files with 7 additions and 2 deletions
|
@ -5,6 +5,12 @@ import StringInput from '../inputs/StringInput'
|
|||
import AutocompleteInput from '../inputs/AutocompleteInput'
|
||||
import SelectInput from '../inputs/SelectInput'
|
||||
|
||||
function tryParseInt(v) {
|
||||
if (v === '') return v
|
||||
if (isNaN(v)) return v
|
||||
return parseFloat(v)
|
||||
}
|
||||
|
||||
class SingleFilterEditor extends React.Component {
|
||||
static propTypes = {
|
||||
filter: React.PropTypes.array.isRequired,
|
||||
|
@ -17,8 +23,7 @@ class SingleFilterEditor extends React.Component {
|
|||
}
|
||||
|
||||
onFilterPartChanged(filterOp, propertyName, filterArgs) {
|
||||
let newFilter = [filterOp, propertyName, ...filterArgs]
|
||||
console.log('filter changed', filterOp, propertyName, filterArgs)
|
||||
let newFilter = [filterOp, propertyName, ...filterArgs.map(tryParseInt)]
|
||||
if(filterOp === 'has' || filterOp === '!has') {
|
||||
newFilter = [filterOp, propertyName]
|
||||
} else if(filterArgs.length === 0) {
|
||||
|
|
Loading…
Reference in a new issue