Browse Source

CategoryOverpassFilter: allow multiple values, e.g. checkbox (combine by 'or')

master
parent
commit
7bbd4a3df8
  1. 20
      src/CategoryOverpassFilter.js

20
src/CategoryOverpassFilter.js

@ -154,14 +154,18 @@ class CategoryOverpassFilter {
applyParam (param) {
this.additionalFilter = Object.keys(param).map(k => {
let value = param[k]
let values = param[k]
let d = this.data[k]
if (value === null) {
if (values === null) {
return null
}
var d = this.data[k]
if (!Array.isArray(values)) {
values = [ values ]
}
let ret = values.map(value => {
if ('values' in d && value in d.values && typeof d.values[value] === 'object' && 'query' in d.values[value]) {
let f = new Filter(d.values[value].query)
return f.def
@ -208,6 +212,16 @@ class CategoryOverpassFilter {
return [ v ]
}).filter(f => f) // remove null values
switch (ret.length) {
case 0:
return null
case 1:
return ret[0]
default:
return { or: ret }
}
}).filter(f => f) // remove null values
if (this.additionalFilter.length === 0) {
this.additionalFilter = []
} else if (this.additionalFilter.length === 1) {

Loading…
Cancel
Save