From 284ef1d7f31ac5bed512039745575aa4ca895cbf Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 17 May 2024 17:13:37 +0200 Subject: [PATCH] feat: remove defaultPanelMode from now After discussion, we prefer to go with decent defaults and see how it goes. --- umap/static/umap/js/modules/panel.js | 6 ++++-- umap/static/umap/js/modules/schema.js | 8 -------- umap/static/umap/js/umap.js | 3 +-- umap/tests/integration/test_browser.py | 8 -------- umap/tests/integration/test_caption.py | 9 --------- umap/tests/integration/test_view_marker.py | 12 ------------ 6 files changed, 5 insertions(+), 41 deletions(-) diff --git a/umap/static/umap/js/modules/panel.js b/umap/static/umap/js/modules/panel.js index 62041f6b..48c17e41 100644 --- a/umap/static/umap/js/modules/panel.js +++ b/umap/static/umap/js/modules/panel.js @@ -2,11 +2,13 @@ import { DomUtil, DomEvent } from '../../vendors/leaflet/leaflet-src.esm.js' import { translate } from './i18n.js' export class Panel { - constructor(map, mode = null) { + constructor(map) { this.parent = map._controlContainer this.map = map this.container = DomUtil.create('div', '', this.parent) - this.mode = mode + // This will be set once according to the panel configurated at load + // or by using panels as popups + this.mode = null this.classname = 'left' DomEvent.disableClickPropagation(this.container) DomEvent.on(this.container, 'contextmenu', DomEvent.stopPropagation) // Do not activate our custom context menu. diff --git a/umap/static/umap/js/modules/schema.js b/umap/static/umap/js/modules/schema.js index 632a226d..3db6f726 100644 --- a/umap/static/umap/js/modules/schema.js +++ b/umap/static/umap/js/modules/schema.js @@ -52,14 +52,6 @@ export const SCHEMA = { label: translate('Display the data layers control'), default: true, }, - defaultPanelMode: { - type: String, - label: translate('Default panel mode'), - choices: [ - ['condensed', translate('Condensed')], - ['expanded', translate('Expanded')], - ], - }, defaultView: { type: String, impacts: [], // no need to update the ui, only useful when loading the map diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 851b9959..0fd4fd63 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -56,7 +56,7 @@ U.Map = L.Map.extend({ if (geojson.geometry) this.options.center = this.latLng(geojson.geometry) this.urls = new U.URLs(this.options.urls) - this.panel = new U.Panel(this, this.options.defaultPanelMode) + this.panel = new U.Panel(this) if (this.hasEditMode()) { this.editPanel = new U.EditPanel(this) this.fullPanel = new U.FullPanel(this) @@ -1174,7 +1174,6 @@ U.Map = L.Map.extend({ 'options.scaleControl', 'options.onLoadPanel', 'options.defaultView', - 'options.defaultPanelMode', 'options.displayPopupFooter', 'options.captionBar', 'options.captionMenus', diff --git a/umap/tests/integration/test_browser.py b/umap/tests/integration/test_browser.py index ea1d7a6a..29f35290 100644 --- a/umap/tests/integration/test_browser.py +++ b/umap/tests/integration/test_browser.py @@ -72,14 +72,6 @@ def test_data_browser_should_be_open(live_server, page, bootstrap, map): expect(page.get_by_text("one polygon in greenland")).to_be_visible() -def test_can_force_panel_mode(live_server, page, bootstrap, map): - map.settings["properties"]["defaultPanelMode"] = "condensed" - map.save() - page.goto(f"{live_server.url}{map.get_absolute_url()}") - panel = page.locator(".panel.left.on") - expect(panel).to_have_class(re.compile(".*condensed.*")) - - def test_data_browser_should_be_filterable(live_server, page, bootstrap, map): page.goto(f"{live_server.url}{map.get_absolute_url()}") expect(page.get_by_title("Features in this layer: 3")).to_be_visible() diff --git a/umap/tests/integration/test_caption.py b/umap/tests/integration/test_caption.py index 33083c40..1458a8a3 100644 --- a/umap/tests/integration/test_caption.py +++ b/umap/tests/integration/test_caption.py @@ -25,12 +25,3 @@ def test_caption(live_server, page, map): 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() - - -def test_can_force_panel_mode(live_server, page, map): - map.settings["properties"]["onLoadPanel"] = "caption" - map.settings["properties"]["defaultPanelMode"] = "expanded" - map.save() - page.goto(f"{live_server.url}{map.get_absolute_url()}") - panel = page.locator(".panel.left.on") - expect(panel).to_have_class(re.compile(".*expanded.*")) diff --git a/umap/tests/integration/test_view_marker.py b/umap/tests/integration/test_view_marker.py index 4602cffd..8dbe3009 100644 --- a/umap/tests/integration/test_view_marker.py +++ b/umap/tests/integration/test_view_marker.py @@ -79,15 +79,3 @@ def test_should_open_popup_panel_on_click(live_server, map, page, bootstrap): # Close popup page.locator("#map").click() expect(panel).to_be_hidden() - - -def test_can_force_popup_panel_mode(live_server, map, page, bootstrap): - map.settings["properties"]["popupShape"] = "Panel" - map.settings["properties"]["defaultPanelMode"] = "condensed" - map.save() - page.goto(f"{live_server.url}{map.get_absolute_url()}") - panel = page.locator(".panel.left.on") - expect(panel).to_be_hidden() - page.locator(".leaflet-marker-icon").click() - expect(panel).to_be_visible() - expect(panel).to_have_class(re.compile(".*condensed.*"))