From 3f6940cd5bf41e6f942c54444173ed52f3dd2ebb Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 11 Jun 2024 14:16:06 +0200 Subject: [PATCH] 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 --- umap/static/umap/js/modules/importer.js | 2 +- umap/static/umap/js/modules/importers/communesfr.js | 1 - umap/static/umap/js/modules/importers/datasets.js | 2 +- umap/static/umap/js/modules/importers/geodatamine.js | 4 +++- umap/static/umap/js/modules/importers/overpass.js | 4 +++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/umap/static/umap/js/modules/importer.js b/umap/static/umap/js/modules/importer.js index 76bb53b8..53dd896c 100644 --- a/umap/static/umap/js/modules/importer.js +++ b/umap/static/umap/js/modules/importer.js @@ -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'), diff --git a/umap/static/umap/js/modules/importers/communesfr.js b/umap/static/umap/js/modules/importers/communesfr.js index 7b08252b..055d4ecf 100644 --- a/umap/static/umap/js/modules/importers/communesfr.js +++ b/umap/static/umap/js/modules/importers/communesfr.js @@ -10,7 +10,6 @@ class Autocomplete extends SingleMixin(BaseAjax) { } } - export class Importer { constructor(map, options) { this.name = options.name || 'Communes' diff --git a/umap/static/umap/js/modules/importers/datasets.js b/umap/static/umap/js/modules/importers/datasets.js index 10445644..7742ebe0 100644 --- a/umap/static/umap/js/modules/importers/datasets.js +++ b/umap/static/umap/js/modules/importers/datasets.js @@ -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', diff --git a/umap/static/umap/js/modules/importers/geodatamine.js b/umap/static/umap/js/modules/importers/geodatamine.js index acfdd049..051a8bbb 100644 --- a/umap/static/umap/js/modules/importers/geodatamine.js +++ b/umap/static/umap/js/modules/importers/geodatamine.js @@ -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}` diff --git a/umap/static/umap/js/modules/importers/overpass.js b/umap/static/umap/js/modules/importers/overpass.js index 58fe5e42..6c28f62b 100644 --- a/umap/static/umap/js/modules/importers/overpass.js +++ b/umap/static/umap/js/modules/importers/overpass.js @@ -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