mirror of
https://github.com/umap-project/umap.git
synced 2025-05-06 06:21:49 +02:00
Support date properties in facet search - fix indents
This commit is contained in:
parent
6cfb65baf0
commit
6572138780
3 changed files with 25 additions and 25 deletions
|
@ -749,18 +749,18 @@ L.U.Map.include({
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
if (facetKeys[key]["type"] === "date") {
|
if (facetKeys[key]["type"] === "date") {
|
||||||
if (!facetCriteria[key]) facetCriteria[key] = {
|
if (!facetCriteria[key]) facetCriteria[key] = {
|
||||||
"min": undefined,
|
"min": undefined,
|
||||||
"max": undefined
|
"max": undefined
|
||||||
}
|
}
|
||||||
if (!this.facets[key]) this.facets[key] = {
|
if (!this.facets[key]) this.facets[key] = {
|
||||||
"type": facetKeys[key]["type"],
|
"type": facetKeys[key]["type"],
|
||||||
"min": undefined,
|
"min": undefined,
|
||||||
"max": undefined
|
"max": undefined
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!facetCriteria[key]) facetCriteria[key] = {
|
if (!facetCriteria[key]) facetCriteria[key] = {
|
||||||
"choices": []
|
"choices": []
|
||||||
}
|
}
|
||||||
if (!this.facets[key]) this.facets[key] = {
|
if (!this.facets[key]) this.facets[key] = {
|
||||||
"type": facetKeys[key]["type"],
|
"type": facetKeys[key]["type"],
|
||||||
"choices": []
|
"choices": []
|
||||||
|
@ -773,18 +773,18 @@ L.U.Map.include({
|
||||||
keys.forEach((key) => {
|
keys.forEach((key) => {
|
||||||
let value = feature.properties[key]
|
let value = feature.properties[key]
|
||||||
if (facetKeys[key]["type"] === "date") {
|
if (facetKeys[key]["type"] === "date") {
|
||||||
value = feature.parseDateField(value)
|
value = feature.parseDateField(value)
|
||||||
if (!!value && (!facetCriteria[key]["min"] || facetCriteria[key]["min"] > value)) {
|
if (!!value && (!facetCriteria[key]["min"] || facetCriteria[key]["min"] > value)) {
|
||||||
facetCriteria[key]["min"] = value
|
facetCriteria[key]["min"] = value
|
||||||
}
|
}
|
||||||
if (!!value && (!facetCriteria[key]["max"] || facetCriteria[key]["max"] < value)) {
|
if (!!value && (!facetCriteria[key]["max"] || facetCriteria[key]["max"] < value)) {
|
||||||
facetCriteria[key]["max"] = value
|
facetCriteria[key]["max"] = value
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!!value && !facetCriteria[key]["choices"].includes(value)) {
|
if (!!value && !facetCriteria[key]["choices"].includes(value)) {
|
||||||
facetCriteria[key]["choices"].push(value)
|
facetCriteria[key]["choices"].push(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -803,7 +803,7 @@ L.U.Map.include({
|
||||||
const fields = keys.map((key) => [
|
const fields = keys.map((key) => [
|
||||||
`facets.${key}`,
|
`facets.${key}`,
|
||||||
{
|
{
|
||||||
handler: facetKeys[key]["type"] === "date" ? 'FacetSearchDate' : 'FacetSearchCheckbox',
|
handler: facetKeys[key]["type"] === "date" ? 'FacetSearchDate' : 'FacetSearchCheckbox',
|
||||||
criteria: facetCriteria[key],
|
criteria: facetCriteria[key],
|
||||||
label: facetKeys[key]["label"]
|
label: facetKeys[key]["label"]
|
||||||
},
|
},
|
||||||
|
|
|
@ -499,13 +499,13 @@ L.U.FeatureMixin = {
|
||||||
let value = this.properties[property]
|
let value = this.properties[property]
|
||||||
const type = criteria["type"]
|
const type = criteria["type"]
|
||||||
if (type === "date") {
|
if (type === "date") {
|
||||||
const min = new Date(criteria["min"])
|
const min = new Date(criteria["min"])
|
||||||
const max = new Date(criteria["max"])
|
const max = new Date(criteria["max"])
|
||||||
value = this.parseDateField(value)
|
value = this.parseDateField(value)
|
||||||
if (!!min && (!value || min > value)) return false
|
if (!!min && (!value || min > value)) return false
|
||||||
if (!!max && (!value || max < value)) return false
|
if (!!max && (!value || max < value)) return false
|
||||||
} else {
|
} else {
|
||||||
const choices = criteria["choices"]
|
const choices = criteria["choices"]
|
||||||
if (choices.length && (!value || !choices.includes(value))) return false
|
if (choices.length && (!value || !choices.includes(value))) return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2034,8 +2034,8 @@ L.U.Map.include({
|
||||||
return (this.options.facetKey || '').split(',').reduce((acc, curr) => {
|
return (this.options.facetKey || '').split(',').reduce((acc, curr) => {
|
||||||
const els = curr.split('|')
|
const els = curr.split('|')
|
||||||
acc[els[0]] = {
|
acc[els[0]] = {
|
||||||
"label": els[1] || els[0],
|
"label": els[1] || els[0],
|
||||||
"type": els[2] || "checkbox"
|
"type": els[2] || "checkbox"
|
||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
|
Loading…
Reference in a new issue