From 115130083dab4a67279e7595ee352d2c37e354d2 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 11 Jun 2024 11:49:00 +0200 Subject: [PATCH] wip: make sure we do not add an invalid overpass URL --- umap/static/umap/js/modules/importers/overpass.js | 10 +++++++--- umap/tests/integration/test_import.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/umap/static/umap/js/modules/importers/overpass.js b/umap/static/umap/js/modules/importers/overpass.js index 67b1e130..012b58b4 100644 --- a/umap/static/umap/js/modules/importers/overpass.js +++ b/umap/static/umap/js/modules/importers/overpass.js @@ -35,7 +35,7 @@ class Autocomplete extends SingleMixin(BaseAjax) { export class Importer { constructor(map, options) { this.map = map - this.name = 'Overpass' + this.name = options.name || 'Overpass' this.baseUrl = options?.url || 'https://overpass-api.de/api/interpreter' } @@ -57,8 +57,12 @@ export class Importer { this.map.help.parse(container) const confirm = () => { - const outMode = container.querySelector('[name=out-mode]').value let tags = container.querySelector('[name=tags]').value + if (!tags) { + this.map.alert.open({content: translate('Please define an expression for the query first')}) + return + } + const outMode = container.querySelector('[name=out-mode]').value if (!tags.startsWith('[')) tags = `[${tags}]` let area = '{south},{west},{north},{east}' if (boundary) area = `area:${boundary}` @@ -68,7 +72,7 @@ export class Importer { importer.format = 'osm' importer.dialog.close() } - L.DomUtil.createButton('', container, 'OK', confirm) + L.DomUtil.createButton('', container, translate('Choose this data'), confirm) importer.dialog.open({ content: container, diff --git a/umap/tests/integration/test_import.py b/umap/tests/integration/test_import.py index 862c1697..e8aa8e30 100644 --- a/umap/tests/integration/test_import.py +++ b/umap/tests/integration/test_import.py @@ -534,7 +534,7 @@ def test_overpass_import_with_bbox(page, live_server, tilelayer, settings): page.get_by_role("link", name="Import data (Ctrl+I)").click() page.get_by_role("button", name="Overpass").click() page.get_by_placeholder("amenity=drinking_water").fill("building") - page.get_by_role("button", name="OK").click() + page.get_by_role("button", name="Choose this data").click() expect(page.get_by_placeholder("Provide an URL here")).to_have_value( "https://my.overpass.io/interpreter?data=[out:json];nwr[building]({south},{west},{north},{east});out geom;" )