Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make sure datalayersControl=expanded does not override onLoadPanel #2101

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
9 changes: 7 additions & 2 deletions umap/static/umap/js/umap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
}
}
},

Expand Down
4 changes: 2 additions & 2 deletions umap/tests/integration/test_edit_datalayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
7 changes: 7 additions & 0 deletions umap/tests/integration/test_querystring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down