From 495286c2616fa9ba7da226abaa269b5046122e75 Mon Sep 17 00:00:00 2001 From: David Larlet Date: Fri, 11 Apr 2025 10:44:01 -0400 Subject: [PATCH] feat: allow to hide the layer switcher from bottom bar --- umap/static/umap/css/bar.css | 2 +- umap/static/umap/js/modules/schema.js | 6 ++++++ umap/static/umap/js/modules/ui/bar.js | 4 ++-- umap/static/umap/js/modules/umap.js | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/css/bar.css b/umap/static/umap/css/bar.css index 8631f788..b62249e7 100644 --- a/umap/static/umap/css/bar.css +++ b/umap/static/umap/css/bar.css @@ -167,7 +167,7 @@ .umap-caption-bar .umap-map-author { margin-inline-end: 10px; } -.umap-caption-bar > button + button:after, +.umap-caption-bar:has(select:not([hidden])) > button + button:after, .umap-caption-bar > button + button:before { content: '|'; padding-inline-start: 10px; diff --git a/umap/static/umap/js/modules/schema.js b/umap/static/umap/js/modules/schema.js index 900243d8..60101690 100644 --- a/umap/static/umap/js/modules/schema.js +++ b/umap/static/umap/js/modules/schema.js @@ -275,6 +275,12 @@ export const SCHEMA = { label: translate('Label key'), inheritable: true, }, + layerSwitcher: { + type: Boolean, + impacts: ['ui'], + label: translate('Do you want to display layer switcher in caption bar?'), + default: true, + }, licence: { type: String, impacts: ['ui'], diff --git a/umap/static/umap/js/modules/ui/bar.js b/umap/static/umap/js/modules/ui/bar.js index d6055b17..d75ddb42 100644 --- a/umap/static/umap/js/modules/ui/bar.js +++ b/umap/static/umap/js/modules/ui/bar.js @@ -180,7 +180,7 @@ const BOTTOM_BAR_TEMPLATE = ` - + ` @@ -233,7 +233,7 @@ export class BottomBar extends WithTemplate { this.elements.layers.hidden = true } else { this.elements.layers.appendChild(Utils.loadTemplate(``)) - this.elements.layers.hidden = false + this.elements.layers.hidden = !this._umap.getProperty('layerSwitcher') const visible = datalayers.filter((datalayer) => datalayer.isVisible()) for (const datalayer of datalayers) { const selected = visible.length === 1 && datalayer.isVisible() ? 'selected' : '' diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index f7dfeaef..abccd5d3 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -836,6 +836,7 @@ export default class Umap { 'properties.displayPopupFooter', 'properties.captionBar', 'properties.captionMenus', + 'properties.layerSwitcher', ]) const builder = new MutatingForm(this, UIFields, { umap: this }) const controlsOptions = DomUtil.createFieldset(