mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
chore: back to this.properties for TableEditor
This commit is contained in:
parent
b63a0f7f2d
commit
f8cb195336
1 changed files with 11 additions and 3 deletions
|
@ -72,7 +72,7 @@ export default class TableEditor extends WithTemplate {
|
||||||
const th = loadTemplate('<th><input type="checkbox" /></th>')
|
const th = loadTemplate('<th><input type="checkbox" /></th>')
|
||||||
const checkbox = th.firstChild
|
const checkbox = th.firstChild
|
||||||
this.elements.header.appendChild(th)
|
this.elements.header.appendChild(th)
|
||||||
for (const property of this.datalayer._propertiesIndex) {
|
for (const property of this.properties) {
|
||||||
this.elements.header.appendChild(
|
this.elements.header.appendChild(
|
||||||
loadTemplate(
|
loadTemplate(
|
||||||
`<th>${property}<button data-property="${property}" class="flat" aria-label="${translate('Advanced actions')}">…</button></th>`
|
`<th>${property}<button data-property="${property}" class="flat" aria-label="${translate('Advanced actions')}">…</button></th>`
|
||||||
|
@ -92,7 +92,7 @@ export default class TableEditor extends WithTemplate {
|
||||||
for (const feature of Object.values(this.datalayer._layers)) {
|
for (const feature of Object.values(this.datalayer._layers)) {
|
||||||
if (feature.isFiltered()) continue
|
if (feature.isFiltered()) continue
|
||||||
if (inBbox && !feature.isOnScreen(bounds)) continue
|
if (inBbox && !feature.isOnScreen(bounds)) continue
|
||||||
const tds = this.datalayer._propertiesIndex.map(
|
const tds = this.properties.map(
|
||||||
(prop) =>
|
(prop) =>
|
||||||
`<td tabindex="0" data-property="${prop}">${feature.properties[prop] || ''}</td>`
|
`<td tabindex="0" data-property="${prop}">${feature.properties[prop] || ''}</td>`
|
||||||
)
|
)
|
||||||
|
@ -101,12 +101,19 @@ export default class TableEditor extends WithTemplate {
|
||||||
this.elements.body.innerHTML = html
|
this.elements.body.innerHTML = html
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetProperties() {
|
||||||
|
this.properties = this.datalayer._propertiesIndex
|
||||||
|
if (this.properties.length === 0) {
|
||||||
|
this.properties = ['name', 'description']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
validateName(name) {
|
validateName(name) {
|
||||||
if (name.includes('.')) {
|
if (name.includes('.')) {
|
||||||
U.Alert.error(translate('Name “{name}” should not contain a dot.', { name }))
|
U.Alert.error(translate('Name “{name}” should not contain a dot.', { name }))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (this.datalayer._propertiesIndex.includes(name)) {
|
if (this.properties.includes(name)) {
|
||||||
U.Alert.error(translate('This name already exists: “{name}”', { name }))
|
U.Alert.error(translate('This name already exists: “{name}”', { name }))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -154,6 +161,7 @@ export default class TableEditor extends WithTemplate {
|
||||||
|
|
||||||
open() {
|
open() {
|
||||||
const id = 'tableeditor:edit'
|
const id = 'tableeditor:edit'
|
||||||
|
this.resetProperties()
|
||||||
this.renderHeaders()
|
this.renderHeaders()
|
||||||
this.elements.body.innerHTML = ''
|
this.elements.body.innerHTML = ''
|
||||||
this.renderBody()
|
this.renderBody()
|
||||||
|
|
Loading…
Reference in a new issue