From 485bd945311fca58b6655229744b61a8a96b255b Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sun, 26 Jan 2025 22:20:19 +0100 Subject: [PATCH] feat: allow to define sortKey at layer level In some situation, we do not want the same sortKey for each layer. --- umap/static/umap/js/modules/data/layer.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/modules/data/layer.js b/umap/static/umap/js/modules/data/layer.js index 9e3f80d03..12086c1a3 100644 --- a/umap/static/umap/js/modules/data/layer.js +++ b/umap/static/umap/js/modules/data/layer.js @@ -462,7 +462,7 @@ export class DataLayer extends ServerStored { } sortFeatures(collection) { - const sortKeys = this._umap.getProperty('sortKey') || U.DEFAULT_LABEL_KEY + const sortKeys = this.getOption('sortKey') || U.DEFAULT_LABEL_KEY return Utils.sortFeatures(collection, sortKeys, U.lang) } @@ -731,11 +731,17 @@ export class DataLayer extends ServerStored { 'options.zoomTo', 'options.fromZoom', 'options.toZoom', + 'options.sortKey', ] builder = new MutatingForm(this, optionsFields, { id: 'datalayer-advanced-properties', }) + builder.on('set', ({ detail }) => { + if (detail.helper.field === 'options.sortKey') { + this.reindex() + } + }) const advancedProperties = DomUtil.createFieldset( container, translate('Advanced properties')