From 887ceee93944e93d6b488229cfa7d12b66655068 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 17 Mar 2025 17:11:38 +0100 Subject: [PATCH 1/3] wip --- umap/static/umap/css/bar.css | 12 ++++++++++-- umap/static/umap/js/modules/ui/bar.js | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/css/bar.css b/umap/static/umap/css/bar.css index 5df3bd87..444a6480 100644 --- a/umap/static/umap/css/bar.css +++ b/umap/static/umap/css/bar.css @@ -166,7 +166,8 @@ .umap-caption-bar button { margin-inline-start: 10px; } -.umap-caption-bar button + button:before { +.umap-caption-bar > button + select:before, +.umap-caption-bar > button + button:before { content: '|'; padding-inline-end: 10px; } @@ -196,7 +197,14 @@ z-index: var(--zindex-panels); } .umap-caption-bar-enabled .umap-caption-bar { - display: block; + display: flex; + align-items: baseline; +} +.umap-caption-bar select { + margin-top: 0; + line-height: initial; + height: initial; + width: auto; } .umap-caption-bar-enabled { --current-footer-height: var(--footer-height); diff --git a/umap/static/umap/js/modules/ui/bar.js b/umap/static/umap/js/modules/ui/bar.js index d7bf77de..32f64e0c 100644 --- a/umap/static/umap/js/modules/ui/bar.js +++ b/umap/static/umap/js/modules/ui/bar.js @@ -167,6 +167,7 @@ const BOTTOM_BAR_TEMPLATE = ` + ` @@ -189,6 +190,17 @@ export class BottomBar extends WithTemplate { this._umap.openBrowser('filters') ) this._slideshow.renderToolbox(this.element) + this.elements.layers.addEventListener('change', () => { + const select = this.elements.layers + const selected = select.options[select.selectedIndex].value + this._umap.eachDataLayer((datalayer) => { + if (datalayer.id === selected) { + datalayer.show() + } else { + datalayer.hide() + } + }) + }) this.redraw() } @@ -201,6 +213,14 @@ export class BottomBar extends WithTemplate { this.elements.caption.hidden = !showMenus this.elements.browse.hidden = !showMenus this.elements.filter.hidden = !showMenus || !this._umap.properties.facetKey + this.elements.layers.innerHTML = '' + this._umap.eachDataLayer((datalayer) => { + this.elements.layers.appendChild( + Utils.loadTemplate( + `` + ) + ) + }) } } From 0dfeb6ede9f704cc283854cc0bd1a752c0452a5c Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 17 Mar 2025 21:52:00 +0100 Subject: [PATCH 2/3] chore: use toggle to switch visibility in datalayer switcher --- umap/static/umap/js/modules/data/layer.js | 6 +++--- umap/static/umap/js/modules/ui/bar.js | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/umap/static/umap/js/modules/data/layer.js b/umap/static/umap/js/modules/data/layer.js index 761945b0..e46d920a 100644 --- a/umap/static/umap/js/modules/data/layer.js +++ b/umap/static/umap/js/modules/data/layer.js @@ -960,11 +960,11 @@ export class DataLayer extends ServerStored { this.propagateHide() } - toggle() { + toggle(status) { // From now on, do not try to how/hidedataChanged // automatically this layer. this._forcedVisibility = true - if (!this.isVisible()) this.show() + if (!this.isVisible() || status) this.show() else this.hide() } @@ -1252,7 +1252,7 @@ export class DataLayer extends ServerStored { this ) } - DomEvent.on(toggle, 'click', this.toggle, this) + DomEvent.on(toggle, 'click', () => this.toggle()) DomEvent.on(zoomTo, 'click', this.zoomTo, this) container.classList.add(this.getHidableClass()) container.classList.toggle('off', !this.isVisible()) diff --git a/umap/static/umap/js/modules/ui/bar.js b/umap/static/umap/js/modules/ui/bar.js index 32f64e0c..146ec3b3 100644 --- a/umap/static/umap/js/modules/ui/bar.js +++ b/umap/static/umap/js/modules/ui/bar.js @@ -194,11 +194,7 @@ export class BottomBar extends WithTemplate { const select = this.elements.layers const selected = select.options[select.selectedIndex].value this._umap.eachDataLayer((datalayer) => { - if (datalayer.id === selected) { - datalayer.show() - } else { - datalayer.hide() - } + datalayer.toggle(datalayer.id === selected) }) }) this.redraw() From ac4339e14047d48135c21c2c060ddd8988eb5e61 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 17 Mar 2025 21:52:18 +0100 Subject: [PATCH 3/3] fixup: only show datalayers with inCaption=true in switcher --- umap/static/umap/js/modules/ui/bar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/umap/static/umap/js/modules/ui/bar.js b/umap/static/umap/js/modules/ui/bar.js index 146ec3b3..05adefd8 100644 --- a/umap/static/umap/js/modules/ui/bar.js +++ b/umap/static/umap/js/modules/ui/bar.js @@ -211,6 +211,7 @@ export class BottomBar extends WithTemplate { this.elements.filter.hidden = !showMenus || !this._umap.properties.facetKey this.elements.layers.innerHTML = '' this._umap.eachDataLayer((datalayer) => { + if (!datalayer.options.inCaption) return this.elements.layers.appendChild( Utils.loadTemplate( ``