mirror of
https://github.com/umap-project/umap.git
synced 2025-05-07 15:01:48 +02:00
Compare commits
No commits in common. "d0156bc7a626c8c6b82ee7c8866cde47780f4df7" and "a7b714c887abb3abf5dd632310030e5b5b2a7c8d" have entirely different histories.
d0156bc7a6
...
a7b714c887
5 changed files with 18 additions and 16 deletions
|
@ -55,6 +55,7 @@ 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 }) {
|
||||
|
|
|
@ -1261,10 +1261,9 @@ export default class Umap extends ServerStored {
|
|||
}
|
||||
}
|
||||
|
||||
render(fields = []) {
|
||||
// Propagate will remove the fields it has already
|
||||
// processed
|
||||
fields = this.propagate(fields)
|
||||
render(fields) {
|
||||
const impacted = this.propagate(fields)
|
||||
if (impacted) return // No need to run a wider reflow
|
||||
|
||||
const impacts = Utils.getImpactsFromSchema(fields)
|
||||
for (const impact of impacts) {
|
||||
|
@ -1328,13 +1327,14 @@ export default class Umap extends ServerStored {
|
|||
})
|
||||
},
|
||||
}
|
||||
let impacted = false
|
||||
for (const [field, impact] of Object.entries(impacts)) {
|
||||
if (!fields.length || fields.includes(field)) {
|
||||
impact()
|
||||
fields = fields.filter((item) => item !== field)
|
||||
impacted = true
|
||||
}
|
||||
}
|
||||
return fields
|
||||
return impacted
|
||||
}
|
||||
|
||||
// TODO: allow to control the default datalayer
|
||||
|
@ -1537,6 +1537,7 @@ 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)
|
||||
|
||||
|
@ -1553,12 +1554,12 @@ export default class Umap extends ServerStored {
|
|||
dataLayer.fromUmapGeoJSON(geojson)
|
||||
}
|
||||
|
||||
// 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.renderUI()
|
||||
this.eachDataLayer((datalayer) => {
|
||||
if (mustReindex) datalayer.reindex()
|
||||
datalayer.redraw()
|
||||
})
|
||||
this.propagate()
|
||||
this._leafletMap._setDefaultCenter()
|
||||
this.isDirty = true
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class LicenceFactory(factory.django.DjangoModelFactory):
|
|||
|
||||
class TileLayerFactory(factory.django.DjangoModelFactory):
|
||||
name = "Test zoom layer"
|
||||
url_template = "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
url_template = "https://{s}.test.org/osmfr/{z}/{x}/{y}.png"
|
||||
attribution = "Test layer attribution"
|
||||
|
||||
class Meta:
|
||||
|
@ -156,6 +156,5 @@ 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)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
@ -26,7 +25,7 @@ def set_timeout(context):
|
|||
@pytest.fixture(autouse=True)
|
||||
def mock_osm_tiles(page):
|
||||
if not bool(os.environ.get("PWDEBUG", False)):
|
||||
page.route(re.compile(r".*tile\..*"), mock_tiles)
|
||||
page.route("*/**/osmfr/**", mock_tiles)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -72,6 +72,8 @@ 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()
|
||||
|
|
Loading…
Reference in a new issue