mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
fix: don't show default label if another is found in features edit
This commit is contained in:
parent
78d6699a81
commit
1a88c11289
1 changed files with 11 additions and 4 deletions
|
@ -236,15 +236,23 @@ class Feature {
|
||||||
container.appendChild(builder.build())
|
container.appendChild(builder.build())
|
||||||
|
|
||||||
const properties = []
|
const properties = []
|
||||||
|
let labelKeyFound = undefined
|
||||||
for (const property of this.datalayer._propertiesIndex) {
|
for (const property of this.datalayer._propertiesIndex) {
|
||||||
if ([U.DEFAULT_LABEL_KEY, 'description'].includes(property)) {
|
if (!labelKeyFound && U.LABEL_KEYS.includes(property)) {
|
||||||
|
labelKeyFound = property
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (property === 'description') {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
properties.push([`properties.${property}`, { label: property }])
|
properties.push([`properties.${property}`, { label: property }])
|
||||||
}
|
}
|
||||||
// We always want name and description for now (properties management to come)
|
// We always want name and description for now (properties management to come)
|
||||||
properties.unshift('properties.description')
|
properties.unshift('properties.description')
|
||||||
properties.unshift(`properties.${U.DEFAULT_LABEL_KEY}`)
|
if (!labelKeyFound) {
|
||||||
|
labelKeyFound = U.DEFAULT_LABEL_KEY
|
||||||
|
}
|
||||||
|
properties.unshift([`properties.${labelKeyFound}`, { label: labelKeyFound }])
|
||||||
builder = new U.FormBuilder(this, properties, {
|
builder = new U.FormBuilder(this, properties, {
|
||||||
id: 'umap-feature-properties',
|
id: 'umap-feature-properties',
|
||||||
})
|
})
|
||||||
|
@ -257,7 +265,7 @@ class Feature {
|
||||||
this.getAdvancedEditActions(advancedActions)
|
this.getAdvancedEditActions(advancedActions)
|
||||||
const onLoad = this._umap.editPanel.open({ content: container })
|
const onLoad = this._umap.editPanel.open({ content: container })
|
||||||
onLoad.then(() => {
|
onLoad.then(() => {
|
||||||
builder.helpers['properties.name'].input.focus()
|
builder.helpers[`properties.${labelKeyFound}`].input.focus()
|
||||||
})
|
})
|
||||||
this._umap.editedFeature = this
|
this._umap.editedFeature = this
|
||||||
if (!this.ui.isOnScreen(this._umap._leafletMap.getBounds())) this.zoomTo(event)
|
if (!this.ui.isOnScreen(this._umap._leafletMap.getBounds())) this.zoomTo(event)
|
||||||
|
@ -330,7 +338,6 @@ class Feature {
|
||||||
}
|
}
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
const value = this.properties[key]
|
const value = this.properties[key]
|
||||||
console.log(key, value)
|
|
||||||
if (value) return value
|
if (value) return value
|
||||||
}
|
}
|
||||||
return this.datalayer.getName()
|
return this.datalayer.getName()
|
||||||
|
|
Loading…
Reference in a new issue