mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-01 02:33:18 +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 AutocompleteInput from '../inputs/AutocompleteInput'
|
||||||
import SelectInput from '../inputs/SelectInput'
|
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 {
|
class SingleFilterEditor extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
filter: React.PropTypes.array.isRequired,
|
filter: React.PropTypes.array.isRequired,
|
||||||
|
@ -17,8 +23,7 @@ class SingleFilterEditor extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onFilterPartChanged(filterOp, propertyName, filterArgs) {
|
onFilterPartChanged(filterOp, propertyName, filterArgs) {
|
||||||
let newFilter = [filterOp, propertyName, ...filterArgs]
|
let newFilter = [filterOp, propertyName, ...filterArgs.map(tryParseInt)]
|
||||||
console.log('filter changed', filterOp, propertyName, filterArgs)
|
|
||||||
if(filterOp === 'has' || filterOp === '!has') {
|
if(filterOp === 'has' || filterOp === '!has') {
|
||||||
newFilter = [filterOp, propertyName]
|
newFilter = [filterOp, propertyName]
|
||||||
} else if(filterArgs.length === 0) {
|
} else if(filterArgs.length === 0) {
|
||||||
|
|
Loading…
Reference in a new issue