Support date properties in facet search - fix indents

This commit is contained in:
flammermann 2023-12-28 00:26:09 +00:00 committed by Yohan Boniface
parent a2e3d6f327
commit 4de6bc6c91
3 changed files with 25 additions and 25 deletions

View file

@ -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"]
},

View file

@ -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
}
}

View file

@ -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
}, {})