diff --git a/umap/static/umap/content.css b/umap/static/umap/content.css index 743af27e..6996ba86 100644 --- a/umap/static/umap/content.css +++ b/umap/static/umap/content.css @@ -262,6 +262,7 @@ ul.umap-autocomplete { } .umap-singleresult { margin-bottom: 10px; + clear: both; } .umap-singleresult div, .umap-multiresult li { diff --git a/umap/static/umap/js/modules/importer.js b/umap/static/umap/js/modules/importer.js index 48c28a65..2aefc9eb 100644 --- a/umap/static/umap/js/modules/importer.js +++ b/umap/static/umap/js/modules/importer.js @@ -103,7 +103,7 @@ export default class Importer { () => plugin.open(this) ) } - this.qs('.importers').toggleAttribute('hidden', true) + this.qs('.importers').toggleAttribute('hidden', false) } for (const type of this.TYPES) { DomUtil.element({ @@ -123,7 +123,10 @@ export default class Importer { } onChange() { - this.qs('[name=link]').toggleAttribute('hidden', !this.url || this.format === 'umap') + this.qs('[name=link]').toggleAttribute( + 'hidden', + !this.url || this.format === 'umap' + ) this.qs('[name=full]').toggleAttribute('hidden', this.format !== 'umap') this.qs('[name=copy]').toggleAttribute('hidden', this.format === 'umap') this.qs('.destination').toggleAttribute('hidden', this.format === 'umap') diff --git a/umap/static/umap/js/modules/importers/geodatamine.js b/umap/static/umap/js/modules/importers/geodatamine.js index 265f2f17..2f059389 100644 --- a/umap/static/umap/js/modules/importers/geodatamine.js +++ b/umap/static/umap/js/modules/importers/geodatamine.js @@ -1,5 +1,6 @@ import { DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js' import { BaseAjax, SingleMixin } from '../autocomplete.js' +import { translate } from '../i18n.js' const BOUNDARY_TYPES = { admin_6: 'département', @@ -10,6 +11,15 @@ const BOUNDARY_TYPES = { local_authority: 'EPCI', } +const TEMPLATE = ` +

GeoDataMine

+ + +` + class Autocomplete extends SingleMixin(BaseAjax) { URL = 'https://geodatamine.fr/boundaries/search?text={q}' @@ -25,18 +35,14 @@ export class Importer { constructor() { this.name = 'GeoDataMine' this.baseUrl = 'https://geodatamine.fr' - this.options = { - theme: null, - boundary: null, - aspoint: false, - } } async open(importer) { + let boundary = null const container = DomUtil.create('div') - DomUtil.createTitle(container, this.name) + container.innerHTML = TEMPLATE const response = await importer.map.request.get(`${this.baseUrl}/themes`) - const select = DomUtil.element({ tagName: 'select', parent: container }) + const select = container.querySelector('select') if (response && response.ok) { const { themes } = await response.json() for (const theme of themes) { @@ -50,11 +56,14 @@ export class Importer { } else { console.error(response) } + const asPoint = container.querySelector('[name=aspoint]') this.autocomplete = new Autocomplete(container, { - on_select: (choice) => (this.options.boundary = choice.item.value), + on_select: (choice) => { + boundary = choice.item.value + }, }) const confirm = () => { - importer.url = `${this.baseUrl}/data/${select.value}/${this.options.boundary}?format=geojson` + importer.url = `${this.baseUrl}/data/${select.value}/${boundary}?format=geojson&aspoint=${asPoint.checked}` importer.format = 'geojson' importer.dialog.close() }