diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index dc3adeff..77e7d0f8 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -671,18 +671,18 @@ const ControlsMixin = { keys.forEach((key) => { if (facetKeys[key]["type"] === "date") { if (!facetCriteria[key]) facetCriteria[key] = { - "min": undefined, - "max": undefined - } + "min": undefined, + "max": undefined + } if (!this.facets[key]) this.facets[key] = { "type": facetKeys[key]["type"], - "min": undefined, - "max": undefined + "min": undefined, + "max": undefined } } else { if (!facetCriteria[key]) facetCriteria[key] = { - "choices": [] - } + "choices": [] + } if (!this.facets[key]) this.facets[key] = { "type": facetKeys[key]["type"], "choices": [] @@ -695,18 +695,18 @@ const ControlsMixin = { keys.forEach((key) => { let value = feature.properties[key] if (facetKeys[key]["type"] === "date") { - value = feature.parseDateField(value) - if (!!value && (!facetCriteria[key]["min"] || facetCriteria[key]["min"] > value)) { - facetCriteria[key]["min"] = value - } - if (!!value && (!facetCriteria[key]["max"] || facetCriteria[key]["max"] < value)) { - facetCriteria[key]["max"] = value - } - } else { - if (!!value && !facetCriteria[key]["choices"].includes(value)) { + value = feature.parseDateField(value) + if (!!value && (!facetCriteria[key]["min"] || facetCriteria[key]["min"] > value)) { + facetCriteria[key]["min"] = value + } + if (!!value && (!facetCriteria[key]["max"] || facetCriteria[key]["max"] < value)) { + facetCriteria[key]["max"] = value + } + } else { + if (!!value && !facetCriteria[key]["choices"].includes(value)) { facetCriteria[key]["choices"].push(value) } - } + } }) }) }) @@ -725,7 +725,7 @@ const ControlsMixin = { const fields = keys.map((key) => [ `facets.${key}`, { - handler: facetKeys[key]["type"] === "date" ? 'FacetSearchDate' : 'FacetSearchCheckbox', + handler: facetKeys[key]["type"] === "date" ? 'FacetSearchDate' : 'FacetSearchCheckbox', criteria: facetCriteria[key], label: facetKeys[key]["label"] }, diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index cffa7f59..297da47b 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -508,13 +508,13 @@ U.FeatureMixin = { let value = this.properties[property] const type = criteria["type"] if (type === "date") { - const min = new Date(criteria["min"]) - const max = new Date(criteria["max"]) - value = this.parseDateField(value) + const min = new Date(criteria["min"]) + const max = new Date(criteria["max"]) + value = this.parseDateField(value) if (!!min && (!value || min > value)) return false - if (!!max && (!value || max < value)) return false + if (!!max && (!value || max < value)) return false } else { - const choices = criteria["choices"] + const choices = criteria["choices"] if (choices.length && (!value || !choices.includes(value))) return false } } diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 22a70c9d..eba08365 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1849,8 +1849,8 @@ U.Map = L.Map.extend({ return (this.options.facetKey || '').split(',').reduce((acc, curr) => { const els = curr.split('|') acc[els[0]] = { - "label": els[1] || els[0], - "type": els[2] || "checkbox" + "label": els[1] || els[0], + "type": els[2] || "checkbox" } return acc }, {})