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.innerHTML = TEMPLATE
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(
plugin.id,
this.container.querySelector('#importers'),

View file

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

View file

@ -10,7 +10,7 @@ export class Importer {
async open(importer) {
const container = DomUtil.create('div', 'formbox')
DomUtil.element({tagName: 'h3', textContent: this.name, parent: container})
DomUtil.element({ tagName: 'h3', textContent: this.name, parent: container })
const select = DomUtil.create('select', '', container)
const noPreset = DomUtil.element({
tagName: 'option',

View file

@ -74,7 +74,9 @@ export class Importer {
})
const confirm = () => {
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
}
importer.url = `${this.baseUrl}/data/${select.value}/${boundary}?format=geojson&aspoint=${asPoint.checked}`

View file

@ -60,7 +60,9 @@ export class Importer {
const confirm = () => {
let tags = container.querySelector('[name=tags]').value
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
}
const outMode = container.querySelector('[name=out-mode]').value