wip: make sure importers are always in the same order

Given they are loaded from an import() call, the order they are
added in IMPORTERS in asynchronous, so we cannot rely on this order
This commit is contained in:
Yohan Boniface 2024-06-11 14:16:06 +02:00
parent c51f8ae5ce
commit 3f6940cd5b
5 changed files with 8 additions and 5 deletions

View file

@ -128,7 +128,7 @@ export default class Importer {
this.container = DomUtil.create('div', 'umap-upload') this.container = DomUtil.create('div', 'umap-upload')
this.container.innerHTML = TEMPLATE this.container.innerHTML = TEMPLATE
if (this.IMPORTERS.length) { if (this.IMPORTERS.length) {
for (const plugin of this.IMPORTERS) { for (const plugin of this.IMPORTERS.sort((a, b) => (a.id > b.id ? 1 : -1))) {
L.DomUtil.createButton( L.DomUtil.createButton(
plugin.id, plugin.id,
this.container.querySelector('#importers'), this.container.querySelector('#importers'),

View file

@ -10,7 +10,6 @@ class Autocomplete extends SingleMixin(BaseAjax) {
} }
} }
export class Importer { export class Importer {
constructor(map, options) { constructor(map, options) {
this.name = options.name || 'Communes' this.name = options.name || 'Communes'

View file

@ -74,7 +74,9 @@ export class Importer {
}) })
const confirm = () => { const confirm = () => {
if (!boundary || !select.value) { if (!boundary || !select.value) {
this.map.alert.open({content: translate('Please choose a theme and a boundary first.')}) this.map.alert.open({
content: translate('Please choose a theme and a boundary first.'),
})
return return
} }
importer.url = `${this.baseUrl}/data/${select.value}/${boundary}?format=geojson&aspoint=${asPoint.checked}` importer.url = `${this.baseUrl}/data/${select.value}/${boundary}?format=geojson&aspoint=${asPoint.checked}`

View file

@ -60,7 +60,9 @@ export class Importer {
const confirm = () => { const confirm = () => {
let tags = container.querySelector('[name=tags]').value let tags = container.querySelector('[name=tags]').value
if (!tags) { if (!tags) {
this.map.alert.open({content: translate('Please define an expression for the query first')}) this.map.alert.open({
content: translate('Please define an expression for the query first'),
})
return return
} }
const outMode = container.querySelector('[name=out-mode]').value const outMode = container.querySelector('[name=out-mode]').value