Fix categorized layers colors palette not updating (#2447)
Some checks are pending
Test & Docs / lint (push) Waiting to run
Test & Docs / docs (push) Waiting to run
Test & Docs / tests (postgresql, 3.10) (push) Waiting to run
Test & Docs / tests (postgresql, 3.12) (push) Waiting to run

fix #2446 

A bunch of small commits, but real fixes are:
29d70552dd
and
d5efe6b8e2
and
8f2bbc6765
This commit is contained in:
Yohan Boniface 2025-01-26 22:21:39 +01:00 committed by GitHub
commit a2936d74de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 9 deletions

View file

@ -213,6 +213,7 @@ class Feature {
if (this._umap.currentFeature === this) { if (this._umap.currentFeature === this) {
this.view() this.view()
} }
this.datalayer.indexProperties(this)
} }
this.redraw() this.redraw()
} }
@ -235,7 +236,7 @@ class Feature {
const properties = [] const properties = []
let labelKeyFound = undefined let labelKeyFound = undefined
for (const property of this.datalayer._propertiesIndex) { for (const property of this.datalayer.allProperties()) {
if (!labelKeyFound && U.LABEL_KEYS.includes(property)) { if (!labelKeyFound && U.LABEL_KEYS.includes(property)) {
labelKeyFound = property labelKeyFound = property
continue continue

View file

@ -88,7 +88,11 @@ const ClassifiedMixin = {
}, },
getColorSchemes: function (classes) { getColorSchemes: function (classes) {
return this.colorSchemes.filter((scheme) => Boolean(colorbrewer[scheme][classes])) const found = this.colorSchemes.filter((scheme) =>
Boolean(colorbrewer[scheme][classes])
)
if (found.length) return found
return [['', translate('Default')]]
}, },
} }
@ -191,7 +195,7 @@ export const Choropleth = FeatureGroup.extend({
'options.choropleth.property', 'options.choropleth.property',
{ {
handler: 'Select', handler: 'Select',
selectOptions: this.datalayer._propertiesIndex, selectOptions: this.datalayer.allProperties(),
label: translate('Choropleth property value'), label: translate('Choropleth property value'),
}, },
], ],
@ -300,7 +304,7 @@ export const Circles = FeatureGroup.extend({
'options.circles.property', 'options.circles.property',
{ {
handler: 'Select', handler: 'Select',
selectOptions: this.datalayer._propertiesIndex, selectOptions: this.datalayer.allProperties(),
label: translate('Property name to compute circles'), label: translate('Property name to compute circles'),
}, },
], ],
@ -377,7 +381,7 @@ export const Categorized = FeatureGroup.extend({
_getValue: function (feature) { _getValue: function (feature) {
const key = const key =
this.datalayer.options.categorized.property || this.datalayer._propertiesIndex[0] this.datalayer.options.categorized.property || this.datalayer.allProperties()[0]
return feature.properties[key] return feature.properties[key]
}, },
@ -420,7 +424,7 @@ export const Categorized = FeatureGroup.extend({
} else { } else {
this.options.colors = colorbrewer?.Accent[this._classes] this.options.colors = colorbrewer?.Accent[this._classes]
? colorbrewer?.Accent[this._classes] ? colorbrewer?.Accent[this._classes]
: U.COLORS // Fixme: move COLORS to modules/ : Utils.COLORS
} }
}, },
@ -430,7 +434,7 @@ export const Categorized = FeatureGroup.extend({
'options.categorized.property', 'options.categorized.property',
{ {
handler: 'Select', handler: 'Select',
selectOptions: this.datalayer._propertiesIndex, selectOptions: this.datalayer.allProperties(),
label: translate('Category property'), label: translate('Category property'),
}, },
], ],
@ -464,7 +468,7 @@ export const Categorized = FeatureGroup.extend({
onEdit: function (field, builder) { onEdit: function (field, builder) {
// Only compute the categories if we're dealing with categorized // Only compute the categories if we're dealing with categorized
if (!field.startsWith('options.categorized')) return if (!field.startsWith('options.categorized') && field !== 'options.type') return
// If user touches the categories, then force manual mode // If user touches the categories, then force manual mode
if (field === 'options.categorized.categories') { if (field === 'options.categorized.categories') {
this.datalayer.options.categorized.mode = 'manual' this.datalayer.options.categorized.mode = 'manual'

View file

@ -104,7 +104,7 @@ export default class TableEditor extends WithTemplate {
} }
resetProperties() { resetProperties() {
this.properties = this.datalayer._propertiesIndex this.properties = this.datalayer.allProperties()
if (this.properties.length === 0) { if (this.properties.length === 0) {
this.properties = [U.DEFAULT_LABEL_KEY, 'description'] this.properties = [U.DEFAULT_LABEL_KEY, 'description']
} }