From 71ceb87fe2f1752795faa079357bf8dd0bce8037 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 4 Sep 2024 12:11:50 +0200 Subject: [PATCH] fix: make sure datalayersControl=expanded does not override onLoadPanel This value of datalayersControl exists for retrocompat only (it's now replaced by onLoadPanel=browser) --- umap/static/umap/js/modules/schema.js | 2 +- umap/static/umap/js/umap.js | 9 +++++++-- umap/tests/integration/test_edit_datalayer.py | 4 ++-- umap/tests/integration/test_querystring.py | 7 +++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/umap/static/umap/js/modules/schema.js b/umap/static/umap/js/modules/schema.js index 233c67420..f2dab9039 100644 --- a/umap/static/umap/js/modules/schema.js +++ b/umap/static/umap/js/modules/schema.js @@ -81,7 +81,7 @@ export const SCHEMA = { impacts: ['ui'], nullable: true, handler: 'DataLayersControl', - label: translate('Display the data layers control'), + label: translate('Display the open browser control'), default: true, }, defaultView: { diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 3493e0821..66194aab4 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -144,7 +144,10 @@ U.Map = L.Map.extend({ delete this.options.displayDataBrowserOnLoad } if (this.options.datalayersControl === 'expanded') { - this.options.onLoadPanel = 'datalayers' + if (!this.options.onLoadPanel) { + this.options.onLoadPanel = 'datalayers' + } + delete this.options.datalayersControl } if (this.options.onLoadPanel === 'facet') { this.options.onLoadPanel = 'datafilters' @@ -280,7 +283,9 @@ U.Map = L.Map.extend({ // Specific case for datalayersControl // which accepts "expanded" value, on top of true/false/null if (L.Util.queryString('datalayersControl') === 'expanded') { - options.onLoadPanel = 'datalayers' + if (!options.onLoadPanel) { + options.onLoadPanel = 'datalayers' + } } }, diff --git a/umap/tests/integration/test_edit_datalayer.py b/umap/tests/integration/test_edit_datalayer.py index 0271bac98..12c92c10d 100644 --- a/umap/tests/integration/test_edit_datalayer.py +++ b/umap/tests/integration/test_edit_datalayer.py @@ -114,7 +114,7 @@ def test_can_change_icon_class(live_server, openmap, page): def test_can_change_name(live_server, openmap, page, datalayer): page.goto( - f"{live_server.url}{openmap.get_absolute_url()}?edit&datalayersControl=expanded" + f"{live_server.url}{openmap.get_absolute_url()}?edit&onLoadPanel=databrowser" ) page.get_by_role("link", name="Manage layers").click() page.locator(".panel.right").get_by_title("Edit", exact=True).click() @@ -133,7 +133,7 @@ def test_can_change_name(live_server, openmap, page, datalayer): def test_can_create_new_datalayer(live_server, openmap, page, datalayer): page.goto( - f"{live_server.url}{openmap.get_absolute_url()}?edit&datalayersControl=expanded" + f"{live_server.url}{openmap.get_absolute_url()}?edit&onLoadPanel=databrowser" ) page.get_by_role("link", name="Manage layers").click() page.get_by_role("button", name="Add a layer").click() diff --git a/umap/tests/integration/test_querystring.py b/umap/tests/integration/test_querystring.py index d4199e905..0694a3352 100644 --- a/umap/tests/integration/test_querystring.py +++ b/umap/tests/integration/test_querystring.py @@ -33,6 +33,13 @@ def test_datalayers_control(map, live_server, datalayer, page): page.goto(f"{live_server.url}{map.get_absolute_url()}?datalayersControl=expanded") expect(control).to_be_visible() expect(browser).to_be_visible() + # Should not override onLoadPanel + page.goto( + f"{live_server.url}{map.get_absolute_url()}?datalayersControl=expanded&onLoadPanel=caption" + ) + expect(control).to_be_visible() + expect(browser).to_be_hidden() + expect(page.locator(".umap-caption")).to_be_visible() def test_can_deactivate_wheel_from_query_string(map, live_server, page):