fix: show non visible layers in caption

fix #1820
This commit is contained in:
Yohan Boniface 2024-05-14 16:26:00 +02:00
parent c58196b285
commit e6b4a54499
4 changed files with 26 additions and 16 deletions

View file

@ -20,7 +20,7 @@ export default class Caption {
})
}
const datalayerContainer = DomUtil.create('div', 'datalayer-container', container)
this.map.eachVisibleDataLayer((datalayer) => this.addDataLayer(datalayer, datalayerContainer))
this.map.eachDataLayer((datalayer) => this.addDataLayer(datalayer, datalayerContainer))
const creditsContainer = DomUtil.create('div', 'credits-container', container)
this.addCredits(creditsContainer)
this.map.panel.open({ content: container })

View file

@ -125,6 +125,7 @@ class DataLayerFactory(factory.django.DjangoModelFactory):
**kwargs["settings"],
}
data.setdefault("_umap_options", {})
kwargs["settings"]["name"] = kwargs["name"]
data["_umap_options"]["name"] = kwargs["name"]
kwargs["geojson"] = ContentFile(json.dumps(data), "foo.json")
return kwargs

View file

@ -0,0 +1,24 @@
import pytest
from playwright.sync_api import expect
from ..base import DataLayerFactory
pytestmark = pytest.mark.django_db
def test_caption(live_server, page, map):
map.settings["properties"]["onLoadPanel"] = "caption"
map.save()
basic = DataLayerFactory(map=map, name="Basic layer")
non_loaded = DataLayerFactory(
map=map, name="Non loaded", settings={"displayOnLoad": False}
)
hidden = DataLayerFactory(map=map, name="Hidden", settings={"inCaption": False})
page.goto(f"{live_server.url}{map.get_absolute_url()}")
panel = page.locator(".umap-caption")
expect(panel).to_be_visible()
expect(panel.locator(".datalayer-legend").get_by_text(basic.name)).to_be_visible()
expect(
panel.locator(".datalayer-legend .off").get_by_text(non_loaded.name)
).to_be_visible()
expect(panel.locator(".datalayer-legend").get_by_text(hidden.name)).to_be_hidden()

View file

@ -188,21 +188,6 @@ def test_remote_layer_should_not_be_used_as_datalayer_for_created_features(
expect(layers).to_have_count(2)
def test_can_hide_datalayer_from_caption(openmap, live_server, datalayer, page):
# Add another DataLayer
other = DataLayerFactory(map=openmap, name="Hidden", settings={"inCaption": False})
page.goto(f"{live_server.url}{openmap.get_absolute_url()}")
toggle = page.get_by_text("About").first
expect(toggle).to_be_visible()
toggle.click()
layers = page.locator(".umap-caption .datalayer-legend")
expect(layers).to_have_count(1)
found = page.locator(".panel.left.on").get_by_text(datalayer.name)
expect(found).to_be_visible()
hidden = page.locator(".panel.left.on").get_by_text(other.name)
expect(hidden).to_be_hidden()
def test_minimap_on_load(map, live_server, datalayer, page):
page.goto(f"{live_server.url}{map.get_absolute_url()}")
expect(page.locator(".leaflet-control-minimap")).to_be_hidden()