From 9eaf33c118eaaf74a6e6863208032d8408aba891 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 27 Mar 2025 10:34:38 +0100 Subject: [PATCH] wip: only show layer selector if there are at least two layers --- umap/static/umap/js/modules/ui/bar.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/umap/static/umap/js/modules/ui/bar.js b/umap/static/umap/js/modules/ui/bar.js index 05adefd8..6e42a4dc 100644 --- a/umap/static/umap/js/modules/ui/bar.js +++ b/umap/static/umap/js/modules/ui/bar.js @@ -210,14 +210,19 @@ export class BottomBar extends WithTemplate { this.elements.browse.hidden = !showMenus 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( - `` + const datalayers = this._umap.datalayersIndex.filter((d) => d.options.inCaption) + if (datalayers.length < 2) { + this.elements.layers.hidden = true + } else { + this.elements.layers.hidden = false + for (const datalayer of datalayers) { + this.elements.layers.appendChild( + Utils.loadTemplate( + `` + ) ) - ) - }) + } + } } }