wip: allow to sync/undo filter added/removed from table editor

This commit is contained in:
Yohan Boniface 2025-03-26 11:21:00 +01:00
parent 6b2038e83e
commit d61e045903
4 changed files with 15 additions and 9 deletions

View file

@ -135,7 +135,13 @@ export default class Facets {
for (const [property, { label, type }] of parsed) {
dumped.push([property, label, type].filter(Boolean).join('|'))
}
return dumped.join(',')
const oldValue = this._umap.properties.facetKey
this._umap.properties.facetKey = dumped.join(',')
this._umap.sync.update(
'properties.facetKey',
this._umap.properties.facetKey,
oldValue
)
}
has(property) {
@ -146,15 +152,13 @@ export default class Facets {
const defined = this.getDefined()
if (!defined.has(property)) {
defined.set(property, { label, type })
this._umap.properties.facetKey = this.dumps(defined)
this._umap.isDirty = true
this.dumps(defined)
}
}
remove(property) {
const defined = this.getDefined()
defined.delete(property)
this._umap.properties.facetKey = this.dumps(defined)
this._umap.isDirty = true
this.dumps(defined)
}
}

View file

@ -117,7 +117,7 @@ export const Choropleth = FeatureGroup.extend({
},
_getValue: function (feature) {
const key = this.datalayer.options.choropleth.property || 'value'
const key = this.datalayer.options.choropleth?.property || 'value'
const value = +feature.properties[key]
if (!Number.isNaN(value)) return value
},
@ -130,12 +130,12 @@ export const Choropleth = FeatureGroup.extend({
this.options.colors = []
return
}
const mode = this.datalayer.options.choropleth.mode
let classes = +this.datalayer.options.choropleth.classes || 5
const mode = this.datalayer.options.choropleth?.mode
let classes = +this.datalayer.options.choropleth?.classes || 5
let breaks
classes = Math.min(classes, values.length)
if (mode === 'manual') {
const manualBreaks = this.datalayer.options.choropleth.breaks
const manualBreaks = this.datalayer.options.choropleth?.breaks
if (manualBreaks) {
breaks = manualBreaks
.split(',')

View file

@ -103,6 +103,7 @@ def test_get_version(map, datalayer):
],
"type": "Point",
},
"id": "ExNTQ",
"properties": {
"_umap_options": {
"color": "DarkCyan",

View file

@ -694,6 +694,7 @@ def test_download(client, map, datalayer):
"coordinates": [14.68896484375, 48.55297816440071],
"type": "Point",
},
"id": "ExNTQ",
"properties": {
"_umap_options": {"color": "DarkCyan", "iconClass": "Ball"},
"description": "Da place anonymous again 755",