mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
chore: use datalayer._propertiesIndex directly
This commit is contained in:
parent
238798acc3
commit
85a4fda0ed
2 changed files with 6 additions and 22 deletions
|
@ -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('<th><input type="checkbox" /></th>')
|
||||
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(
|
||||
`<th>${property}<button data-property="${property}" class="flat" aria-label="${translate('Advanced actions')}">…</button></th>`
|
||||
|
@ -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) =>
|
||||
`<td tabindex="0" data-property="${prop}">${feature.properties[prop] || ''}</td>`
|
||||
)
|
||||
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue