From 29d70552dd1f68eef4ba9929c0db17dd785a73e9 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 24 Jan 2025 18:19:57 +0100 Subject: [PATCH 1/5] fix: always index properties when feature properties as changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We want the datalayer index properties to be updated when a user set a property on the feature, as this property name may not yet be in the index (which is used later for autocomplete, select…). --- umap/static/umap/js/modules/data/features.js | 1 + 1 file changed, 1 insertion(+) diff --git a/umap/static/umap/js/modules/data/features.js b/umap/static/umap/js/modules/data/features.js index 18ce98f9..04bd0132 100644 --- a/umap/static/umap/js/modules/data/features.js +++ b/umap/static/umap/js/modules/data/features.js @@ -213,6 +213,7 @@ class Feature { if (this._umap.currentFeature === this) { this.view() } + this.datalayer.indexProperties(this) } this.redraw() } From 609b251303621479407f72ea84664eba1c3edd2b Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 24 Jan 2025 18:21:29 +0100 Subject: [PATCH 2/5] chore: use datalayer.allProperties() instead of private property --- umap/static/umap/js/modules/data/features.js | 2 +- .../static/umap/js/modules/rendering/layers/classified.js | 8 ++++---- umap/static/umap/js/modules/tableeditor.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/umap/static/umap/js/modules/data/features.js b/umap/static/umap/js/modules/data/features.js index 04bd0132..5a021ecd 100644 --- a/umap/static/umap/js/modules/data/features.js +++ b/umap/static/umap/js/modules/data/features.js @@ -236,7 +236,7 @@ class Feature { const properties = [] let labelKeyFound = undefined - for (const property of this.datalayer._propertiesIndex) { + for (const property of this.datalayer.allProperties()) { if (!labelKeyFound && U.LABEL_KEYS.includes(property)) { labelKeyFound = property continue diff --git a/umap/static/umap/js/modules/rendering/layers/classified.js b/umap/static/umap/js/modules/rendering/layers/classified.js index 52f9127d..bf581288 100644 --- a/umap/static/umap/js/modules/rendering/layers/classified.js +++ b/umap/static/umap/js/modules/rendering/layers/classified.js @@ -191,7 +191,7 @@ export const Choropleth = FeatureGroup.extend({ 'options.choropleth.property', { handler: 'Select', - selectOptions: this.datalayer._propertiesIndex, + selectOptions: this.datalayer.allProperties(), label: translate('Choropleth property value'), }, ], @@ -300,7 +300,7 @@ export const Circles = FeatureGroup.extend({ 'options.circles.property', { handler: 'Select', - selectOptions: this.datalayer._propertiesIndex, + selectOptions: this.datalayer.allProperties(), label: translate('Property name to compute circles'), }, ], @@ -377,7 +377,7 @@ export const Categorized = FeatureGroup.extend({ _getValue: function (feature) { const key = - this.datalayer.options.categorized.property || this.datalayer._propertiesIndex[0] + this.datalayer.options.categorized.property || this.datalayer.allProperties()[0] return feature.properties[key] }, @@ -430,7 +430,7 @@ export const Categorized = FeatureGroup.extend({ 'options.categorized.property', { handler: 'Select', - selectOptions: this.datalayer._propertiesIndex, + selectOptions: this.datalayer.allProperties(), label: translate('Category property'), }, ], diff --git a/umap/static/umap/js/modules/tableeditor.js b/umap/static/umap/js/modules/tableeditor.js index 255f26cb..bdfe8619 100644 --- a/umap/static/umap/js/modules/tableeditor.js +++ b/umap/static/umap/js/modules/tableeditor.js @@ -104,7 +104,7 @@ export default class TableEditor extends WithTemplate { } resetProperties() { - this.properties = this.datalayer._propertiesIndex + this.properties = this.datalayer.allProperties() if (this.properties.length === 0) { this.properties = [U.DEFAULT_LABEL_KEY, 'description'] } From 8111cf55221c025c0c72e86dfca215a144168f64 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 24 Jan 2025 18:22:33 +0100 Subject: [PATCH 3/5] fix: add a label for default colors scheme in categorized layer type --- umap/static/umap/js/modules/rendering/layers/classified.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/modules/rendering/layers/classified.js b/umap/static/umap/js/modules/rendering/layers/classified.js index bf581288..039df186 100644 --- a/umap/static/umap/js/modules/rendering/layers/classified.js +++ b/umap/static/umap/js/modules/rendering/layers/classified.js @@ -88,7 +88,11 @@ const ClassifiedMixin = { }, 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')]] }, } From d5efe6b8e260863527b9a6a15fb9059d570f2559 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 24 Jan 2025 18:23:41 +0100 Subject: [PATCH 4/5] fix: get COLORS from Utils now that it has been moved there --- umap/static/umap/js/modules/rendering/layers/classified.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/umap/static/umap/js/modules/rendering/layers/classified.js b/umap/static/umap/js/modules/rendering/layers/classified.js index 039df186..ff02c33f 100644 --- a/umap/static/umap/js/modules/rendering/layers/classified.js +++ b/umap/static/umap/js/modules/rendering/layers/classified.js @@ -424,7 +424,7 @@ export const Categorized = FeatureGroup.extend({ } else { this.options.colors = colorbrewer?.Accent[this._classes] ? colorbrewer?.Accent[this._classes] - : U.COLORS // Fixme: move COLORS to modules/ + : Utils.COLORS } }, From 8f2bbc6765010c001d12531ab1d4aabca46a177f Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 24 Jan 2025 18:24:33 +0100 Subject: [PATCH 5/5] fix: re-compute layer settings when type changed --- umap/static/umap/js/modules/rendering/layers/classified.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/umap/static/umap/js/modules/rendering/layers/classified.js b/umap/static/umap/js/modules/rendering/layers/classified.js index ff02c33f..138f53b0 100644 --- a/umap/static/umap/js/modules/rendering/layers/classified.js +++ b/umap/static/umap/js/modules/rendering/layers/classified.js @@ -468,7 +468,7 @@ export const Categorized = FeatureGroup.extend({ onEdit: function (field, builder) { // 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 (field === 'options.categorized.categories') { this.datalayer.options.categorized.mode = 'manual'