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

View file

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

View file

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

View file

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