diff --git a/umap/settings/base.py b/umap/settings/base.py index b63c72f4..4a925c92 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -260,6 +260,7 @@ UMAP_DEFAULT_EDIT_STATUS = None UMAP_DEFAULT_FEATURES_HAVE_OWNERS = False UMAP_HOME_FEED = "latest" UMAP_EXPERIMENTAL_IMPORTERS = { + # "overpass": {"url": "https://overpass-api.de/api/interpreter"}, # "geodatamine": {}, # "communesfr": {}, # "presets": { diff --git a/umap/static/umap/js/modules/importers/communesfr.js b/umap/static/umap/js/modules/importers/communesfr.js index 128423e5..9c66e3c6 100644 --- a/umap/static/umap/js/modules/importers/communesfr.js +++ b/umap/static/umap/js/modules/importers/communesfr.js @@ -10,9 +10,10 @@ class Autocomplete extends SingleMixin(BaseAjax) { } } + export class Importer { - constructor() { - this.name = 'Communes' + constructor(map, options) { + this.name = options.name || 'Communes' } async open(importer) { @@ -24,6 +25,7 @@ export class Importer { textContent: "Importer les contours d'une commune française.", }) const options = { + placeholder: 'Commune…', url: 'https://geo.api.gouv.fr/communes?nom={q}&limit=5', on_select: (choice) => { importer.url = `https://geo.api.gouv.fr/communes?code=${choice.item.value}&format=geojson&geometry=contour` diff --git a/umap/static/umap/js/modules/importers/presets.js b/umap/static/umap/js/modules/importers/datasets.js similarity index 63% rename from umap/static/umap/js/modules/importers/presets.js rename to umap/static/umap/js/modules/importers/datasets.js index 78325943..8f6be2b6 100644 --- a/umap/static/umap/js/modules/importers/presets.js +++ b/umap/static/umap/js/modules/importers/datasets.js @@ -3,24 +3,25 @@ import { translate } from '../i18n.js' export class Importer { constructor(map, options) { - this.name = 'Presets' + this.name = options.name || 'Datasets' this.choices = options?.choices } async open(importer) { const container = DomUtil.create('div', 'formbox') + DomUtil.element({tagName: 'h3', textContent: this.name, parent: container}) const select = DomUtil.create('select', '', container) const noPreset = DomUtil.element({ tagName: 'option', parent: select, value: '', - textContent: translate('Choose a preset'), + textContent: translate('Choose a dataset'), }) - for (const preset of this.choices) { + for (const dataset of this.choices) { const option = DomUtil.create('option', '', select) - option.value = preset.url - option.textContent = preset.label - option.dataset.format = preset.format || 'geojson' + option.value = dataset.url + option.textContent = dataset.label + option.dataset.format = dataset.format || 'geojson' } const confirm = () => { if (select.value) { @@ -29,11 +30,11 @@ export class Importer { } importer.dialog.close() } - L.DomUtil.createButton('', container, 'OK', confirm) + L.DomUtil.createButton('', container, translate('Choose this dataset'), confirm) importer.dialog.open({ content: container, - className: 'presets dark', + className: 'datasets dark', }) } } diff --git a/umap/static/umap/js/umap.core.js b/umap/static/umap/js/umap.core.js index 9d23e886..c0aac7c7 100644 --- a/umap/static/umap/js/umap.core.js +++ b/umap/static/umap/js/umap.core.js @@ -139,7 +139,7 @@ L.DomUtil.createButtonIcon = (parent, className, title, size = 16) => { L.DomUtil.createTitle = (parent, text, className, tag = 'h3') => { const title = L.DomUtil.create(tag, '', parent) - L.DomUtil.createIcon(title, className) + if (className) L.DomUtil.createIcon(title, className) L.DomUtil.add('span', '', title, text) return title }