diff --git a/umap/static/umap/js/modules/sync/updaters.js b/umap/static/umap/js/modules/sync/updaters.js index bcc311d1..eafb51f2 100644 --- a/umap/static/umap/js/modules/sync/updaters.js +++ b/umap/static/umap/js/modules/sync/updaters.js @@ -55,7 +55,6 @@ export class DataLayerUpdater extends BaseUpdater { upsert({ value }) { // Upsert only happens when a new datalayer is created. this._umap.createDataLayer(value, false) - this._umap.render([]) } update({ key, metadata, value }) { diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index 68a325d2..56199b08 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -1261,9 +1261,10 @@ export default class Umap extends ServerStored { } } - render(fields) { - const impacted = this.propagate(fields) - if (impacted) return // No need to run a wider reflow + render(fields = []) { + // Propagate will remove the fields it has already + // processed + fields = this.propagate(fields) const impacts = Utils.getImpactsFromSchema(fields) for (const impact of impacts) { @@ -1327,14 +1328,13 @@ export default class Umap extends ServerStored { }) }, } - let impacted = false for (const [field, impact] of Object.entries(impacts)) { if (!fields.length || fields.includes(field)) { impact() - impacted = true + fields = fields.filter((item) => item !== field) } } - return impacted + return fields } // TODO: allow to control the default datalayer @@ -1537,7 +1537,6 @@ export default class Umap extends ServerStored { importRaw(rawData) { const importedData = JSON.parse(rawData) - const mustReindex = 'sortKey' in Object.keys(importedData.properties) this.setProperties(importedData.properties) @@ -1554,12 +1553,12 @@ export default class Umap extends ServerStored { dataLayer.fromUmapGeoJSON(geojson) } - this._leafletMap.renderUI() - this.eachDataLayer((datalayer) => { - if (mustReindex) datalayer.reindex() - datalayer.redraw() - }) - this.propagate() + // For now render->propagate expect a `properties.` prefix. + // Remove this when we have refactored schema and render. + const fields = Object.keys(importedData.properties).map( + (field) => `properties.${field}` + ) + this.render(fields) this._leafletMap._setDefaultCenter() this.isDirty = true } diff --git a/umap/tests/base.py b/umap/tests/base.py index 7833d00a..81aaac3c 100644 --- a/umap/tests/base.py +++ b/umap/tests/base.py @@ -42,7 +42,7 @@ class LicenceFactory(factory.django.DjangoModelFactory): class TileLayerFactory(factory.django.DjangoModelFactory): name = "Test zoom layer" - url_template = "https://{s}.test.org/osmfr/{z}/{x}/{y}.png" + url_template = "https://tile.openstreetmap.org/{z}/{x}/{y}.png" attribution = "Test layer attribution" class Meta: @@ -156,5 +156,6 @@ def login_required(response): def mock_tiles(route): + print("Intercepted route", route.request.url) path = Path(__file__).parent / "fixtures/empty_tile.png" route.fulfill(path=path) diff --git a/umap/tests/integration/conftest.py b/umap/tests/integration/conftest.py index 9bf1aad9..733cec4d 100644 --- a/umap/tests/integration/conftest.py +++ b/umap/tests/integration/conftest.py @@ -1,4 +1,5 @@ import os +import re import subprocess import time from pathlib import Path @@ -25,7 +26,7 @@ def set_timeout(context): @pytest.fixture(autouse=True) def mock_osm_tiles(page): if not bool(os.environ.get("PWDEBUG", False)): - page.route("*/**/osmfr/**", mock_tiles) + page.route(re.compile(r".*tile\..*"), mock_tiles) @pytest.fixture diff --git a/umap/tests/integration/test_import.py b/umap/tests/integration/test_import.py index 11413eaa..757a766f 100644 --- a/umap/tests/integration/test_import.py +++ b/umap/tests/integration/test_import.py @@ -72,8 +72,6 @@ def test_umap_import_from_file(live_server, tilelayer, page): def test_umap_import_from_textarea(live_server, tilelayer, page, settings): - page.route("https://tile.openstreetmap.fr/hot/**", mock_tiles) - settings.UMAP_ALLOW_ANONYMOUS = True page.goto(f"{live_server.url}/map/new/") page.get_by_role("button", name="Open browser").click()