From 85a4fda0ed6e3710ac986c6a648c7e2fe8de6e6a Mon Sep 17 00:00:00 2001 From: David Larlet Date: Fri, 12 Jul 2024 11:51:04 -0400 Subject: [PATCH] chore: use datalayer._propertiesIndex directly --- umap/static/umap/js/modules/tableeditor.js | 23 ++-------------------- umap/static/umap/js/umap.layer.js | 5 ++++- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/umap/static/umap/js/modules/tableeditor.js b/umap/static/umap/js/modules/tableeditor.js index 21cc8778..b42cbb6a 100644 --- a/umap/static/umap/js/modules/tableeditor.js +++ b/umap/static/umap/js/modules/tableeditor.js @@ -20,7 +20,6 @@ export default class TableEditor extends WithTemplate { this.map = this.datalayer.map this.contextmenu = new ContextMenu({ className: 'dark' }) this.table = this.loadTemplate(TEMPLATE) - this.resetProperties() if (!this.datalayer.isRemoteLayer()) { this.elements.body.addEventListener('dblclick', (event) => { if (event.target.closest('[data-property]')) this.editCell(event.target) @@ -73,7 +72,7 @@ export default class TableEditor extends WithTemplate { const th = loadTemplate('') const checkbox = th.firstChild this.elements.header.appendChild(th) - for (const property of this.properties) { + for (const property of this.datalayer._propertiesIndex) { this.elements.header.appendChild( loadTemplate( `${property}` @@ -93,7 +92,7 @@ export default class TableEditor extends WithTemplate { for (const feature of Object.values(this.datalayer._layers)) { if (feature.isFiltered()) continue if (inBbox && !feature.isOnScreen(bounds)) continue - const tds = this.properties.map( + const tds = this.datalayer._propertiesIndex.map( (prop) => `${feature.properties[prop] || ''}` ) @@ -102,23 +101,6 @@ export default class TableEditor extends WithTemplate { this.elements.body.innerHTML = html } - compileProperties() { - this.resetProperties() - if (this.properties.length === 0) this.properties = ['name'] - this.properties.sort() - this.field_properties = [] - for (let i = 0; i < this.properties.length; i++) { - this.field_properties.push([ - `properties.${this.properties[i]}`, - { wrapper: 'td' }, - ]) - } - } - - resetProperties() { - this.properties = this.datalayer._propertiesIndex - } - validateName(name) { if (name.includes('.')) { U.Alert.error(translate('Invalide property name: {name}', { name: name })) @@ -172,7 +154,6 @@ export default class TableEditor extends WithTemplate { open() { const id = 'tableeditor:edit' - this.compileProperties() this.renderHeaders() this.elements.body.innerHTML = '' this.renderBody() diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 2fef9178..ca3da686 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -412,7 +412,9 @@ U.Layer.Categorized = U.RelativeColorLayer.extend({ if (colorbrewer[colorScheme]?.[this._classes]) { this.options.colors = colorbrewer[colorScheme][this._classes] } else { - this.options.colors = colorbrewer?.Accent[this._classes] ? colorbrewer?.Accent[this._classes] : U.COLORS + this.options.colors = colorbrewer?.Accent[this._classes] + ? colorbrewer?.Accent[this._classes] + : U.COLORS } }, @@ -1045,6 +1047,7 @@ U.DataLayer = L.Evented.extend({ if (name.indexOf('_') === 0) return if (L.Util.indexOf(this._propertiesIndex, name) !== -1) return this._propertiesIndex.push(name) + this._propertiesIndex.sort() }, deindexProperty: function (name) {