Merge pull request #1755 from umap-project/browser-no-control
fix: make sure we do not render browser in map fragment
This commit is contained in:
commit
62e7e3c01a
3 changed files with 32 additions and 7 deletions
|
@ -213,13 +213,9 @@ class Map(NamedModel):
|
||||||
"STATIC_URL": settings.STATIC_URL,
|
"STATIC_URL": settings.STATIC_URL,
|
||||||
"editMode": "disabled",
|
"editMode": "disabled",
|
||||||
"hash": False,
|
"hash": False,
|
||||||
"attributionControl": False,
|
|
||||||
"scrollWheelZoom": False,
|
"scrollWheelZoom": False,
|
||||||
"umapAttributionControl": False,
|
|
||||||
"noControl": True,
|
"noControl": True,
|
||||||
"umap_id": self.pk,
|
"umap_id": self.pk,
|
||||||
"onLoadPanel": "none",
|
|
||||||
"captionBar": False,
|
|
||||||
"schema": self.extra_schema,
|
"schema": self.extra_schema,
|
||||||
"slideshow": {},
|
"slideshow": {},
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,13 +197,16 @@ U.Map = L.Map.extend({
|
||||||
|
|
||||||
this.slideshow = new U.Slideshow(this, this.options.slideshow)
|
this.slideshow = new U.Slideshow(this, this.options.slideshow)
|
||||||
this.permissions = new U.MapPermissions(this)
|
this.permissions = new U.MapPermissions(this)
|
||||||
this.initCaptionBar()
|
|
||||||
if (this.hasEditMode()) {
|
if (this.hasEditMode()) {
|
||||||
this.editTools = new U.Editable(this)
|
this.editTools = new U.Editable(this)
|
||||||
this.renderEditToolbar()
|
this.renderEditToolbar()
|
||||||
}
|
}
|
||||||
this.initShortcuts()
|
this.initShortcuts()
|
||||||
this.onceDataLoaded(function () {
|
this.onceDataLoaded(function () {
|
||||||
|
const slug = L.Util.queryString('feature')
|
||||||
|
if (slug && this.features_index[slug]) this.features_index[slug].view()
|
||||||
|
if (this.options.noControl) return
|
||||||
|
this.initCaptionBar()
|
||||||
if (L.Util.queryString('share')) {
|
if (L.Util.queryString('share')) {
|
||||||
this.share.open()
|
this.share.open()
|
||||||
} else if (this.options.onLoadPanel === 'databrowser') {
|
} else if (this.options.onLoadPanel === 'databrowser') {
|
||||||
|
@ -218,8 +221,6 @@ U.Map = L.Map.extend({
|
||||||
} else if (['facet', 'datafilters'].includes(this.options.onLoadPanel)) {
|
} else if (['facet', 'datafilters'].includes(this.options.onLoadPanel)) {
|
||||||
this.openFacet()
|
this.openFacet()
|
||||||
}
|
}
|
||||||
const slug = L.Util.queryString('feature')
|
|
||||||
if (slug && this.features_index[slug]) this.features_index[slug].view()
|
|
||||||
if (L.Util.queryString('edit')) {
|
if (L.Util.queryString('edit')) {
|
||||||
if (this.hasEditMode()) this.enableEdit()
|
if (this.hasEditMode()) this.enableEdit()
|
||||||
// Sometimes users share the ?edit link by mistake, let's remove
|
// Sometimes users share the ?edit link by mistake, let's remove
|
||||||
|
|
28
umap/tests/integration/test_map_list.py
Normal file
28
umap/tests/integration/test_map_list.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import pytest
|
||||||
|
from playwright.sync_api import expect
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.django_db
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_not_render_any_control(live_server, tilelayer, page, map):
|
||||||
|
map.settings["properties"]["onLoadPanel"] = "databrowser"
|
||||||
|
map.settings["properties"]["miniMap"] = True
|
||||||
|
map.settings["properties"]["captionBar"] = True
|
||||||
|
map.save()
|
||||||
|
# Make sure those controls are visible in normal view
|
||||||
|
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||||
|
expect(page.locator(".leaflet-control-minimap")).to_be_visible()
|
||||||
|
expect(page.locator(".umap-browser")).to_be_visible()
|
||||||
|
expect(page.locator(".umap-caption-bar")).to_be_visible()
|
||||||
|
expect(page.locator(".leaflet-control-zoom")).to_be_visible()
|
||||||
|
expect(page.locator(".leaflet-control-attribution")).to_be_visible()
|
||||||
|
|
||||||
|
# Now load home page to have the list view
|
||||||
|
page.goto(live_server.url)
|
||||||
|
map_el = page.locator(".map_fragment")
|
||||||
|
expect(map_el).to_be_visible()
|
||||||
|
expect(map_el.locator(".leaflet-control-minimap")).to_be_hidden()
|
||||||
|
expect(map_el.locator(".umap-browser")).to_be_hidden()
|
||||||
|
expect(map_el.locator(".umap-caption-bar")).to_be_hidden()
|
||||||
|
expect(map_el.locator(".leaflet-control-zoom")).to_be_hidden()
|
||||||
|
expect(map_el.locator(".leaflet-control-attribution")).to_be_hidden()
|
Loading…
Reference in a new issue