mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 11:32:38 +02:00
fix: remote data loading on import from umap backup
This commit is contained in:
parent
0e56e71e87
commit
b05e6ec28c
3 changed files with 101 additions and 3 deletions
|
@ -81,7 +81,7 @@ export class DataLayer {
|
|||
this.connectToMap()
|
||||
this.permissions = new DataLayerPermissions(this._umap, this)
|
||||
|
||||
this._needsFetch = this.createdOnServer
|
||||
this._needsFetch = this.createdOnServer || this.isRemoteLayer()
|
||||
if (!this.createdOnServer) {
|
||||
if (this.showAtLoad()) this.show()
|
||||
}
|
||||
|
@ -261,8 +261,11 @@ export class DataLayer {
|
|||
if (geojson._storage) geojson._umap_options = geojson._storage // Retrocompat
|
||||
geojson._umap_options.id = this.id
|
||||
if (geojson._umap_options) this.setOptions(geojson._umap_options)
|
||||
if (this.isRemoteLayer()) await this.fetchRemoteData()
|
||||
else this.fromGeoJSON(geojson, false)
|
||||
if (this.isRemoteLayer()) {
|
||||
await this.fetchRemoteData()
|
||||
} else {
|
||||
this.fromGeoJSON(geojson, false)
|
||||
}
|
||||
}
|
||||
|
||||
clear() {
|
||||
|
|
55
umap/tests/fixtures/remote_data.umap
vendored
Normal file
55
umap/tests/fixtures/remote_data.umap
vendored
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"type": "umap",
|
||||
"uri": "http://localhost:8020/fr/map/carte-sans-nom_128#6/50.233/6.910",
|
||||
"properties": {
|
||||
"easing": false,
|
||||
"embedControl": true,
|
||||
"fullscreenControl": true,
|
||||
"searchControl": true,
|
||||
"datalayersControl": true,
|
||||
"zoomControl": true,
|
||||
"permanentCreditBackground": true,
|
||||
"slideshow": {},
|
||||
"captionMenus": true,
|
||||
"captionBar": false,
|
||||
"limitBounds": {},
|
||||
"overlay": null,
|
||||
"licence": "",
|
||||
"description": "",
|
||||
"name": "Carte sans nom",
|
||||
"displayPopupFooter": false,
|
||||
"miniMap": false,
|
||||
"moreControl": true,
|
||||
"scaleControl": true,
|
||||
"scrollWheelZoom": true,
|
||||
"zoom": 6
|
||||
},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
6.734619140625,
|
||||
50.359480346298696
|
||||
]
|
||||
},
|
||||
"layers": [
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [],
|
||||
"_umap_options": {
|
||||
"name": "Itinéraire D",
|
||||
"color": "#d34e8d",
|
||||
"editMode": "advanced",
|
||||
"browsable": true,
|
||||
"inCaption": true,
|
||||
"remoteData": {
|
||||
"url": "https://remote.org/data.json",
|
||||
"format": "geojson"
|
||||
},
|
||||
"permissions": {
|
||||
"edit_status": 0
|
||||
},
|
||||
"displayOnLoad": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -650,6 +650,46 @@ def test_create_remote_data(page, live_server, tilelayer):
|
|||
)
|
||||
|
||||
|
||||
def test_create_remote_data_from_umap_backup(page, live_server, tilelayer):
|
||||
def handle(route):
|
||||
route.fulfill(
|
||||
json={
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [4.3375, 51.2707],
|
||||
},
|
||||
}
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
page.route("https://remote.org/data.json", handle)
|
||||
page.goto(f"{live_server.url}/map/new/")
|
||||
expect(page.locator(".leaflet-marker-icon")).to_be_hidden()
|
||||
page.get_by_title("Import data").click()
|
||||
file_input = page.locator("input[type='file']")
|
||||
with page.expect_file_chooser() as fc_info:
|
||||
file_input.click()
|
||||
file_chooser = fc_info.value
|
||||
path = Path(__file__).parent.parent / "fixtures/remote_data.umap"
|
||||
file_chooser.set_files(path)
|
||||
page.get_by_role("button", name="Import data", exact=True).click()
|
||||
page.get_by_title("Open browser").click()
|
||||
layers = page.locator(".umap-browser .datalayer")
|
||||
expect(layers).to_have_count(1)
|
||||
expect(page.locator(".leaflet-marker-icon")).to_be_visible()
|
||||
page.get_by_role("button", name="Edit", exact=True).click()
|
||||
page.locator("summary").filter(has_text="Remote data").click()
|
||||
expect(page.locator('.panel input[name="url"]')).to_have_value(
|
||||
"https://remote.org/data.json"
|
||||
)
|
||||
|
||||
|
||||
def test_import_geojson_from_url(page, live_server, tilelayer):
|
||||
def handle(route):
|
||||
route.fulfill(
|
||||
|
|
Loading…
Reference in a new issue