From 41e7b34813d9bfebeb01dd16553b8751e13f27b9 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 6 Mar 2024 20:00:07 +0100 Subject: [PATCH] wip: allow to open browser in condensed mode --- umap/static/umap/js/modules/browser.js | 1 + umap/static/umap/js/modules/schema.js | 1 + umap/static/umap/js/umap.js | 26 +++++++++++++++----------- umap/static/umap/js/umap.ui.js | 3 ++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/umap/static/umap/js/modules/browser.js b/umap/static/umap/js/modules/browser.js index 288b7a35..1e80b695 100644 --- a/umap/static/umap/js/modules/browser.js +++ b/umap/static/umap/js/modules/browser.js @@ -73,6 +73,7 @@ export default class Browser { addDataLayer(datalayer, parent) { let className = `orderable datalayer ${datalayer.getHidableClass()}` + if (this.map.ui.PANEL_MODE !== 'condensed') className += ' show-list' const container = DomUtil.create( 'div', className, diff --git a/umap/static/umap/js/modules/schema.js b/umap/static/umap/js/modules/schema.js index 05728a94..97f3d777 100644 --- a/umap/static/umap/js/modules/schema.js +++ b/umap/static/umap/js/modules/schema.js @@ -273,6 +273,7 @@ export const SCHEMA = { ['none', translate('None')], ['caption', translate('Caption')], ['databrowser', translate('Data browser')], + ['datalayers', translate('Layers')], ['facet', translate('Facet search')], ], default: 'none', diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 5159e6d0..16691541 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -141,7 +141,7 @@ U.Map = L.Map.extend({ delete this.options.displayDataBrowserOnLoad } if (this.options.datalayersControl === 'expanded') { - this.options.onLoadPanel = 'databrowser' + this.options.onLoadPanel = 'datalayers' } this.ui.on( @@ -214,14 +214,19 @@ U.Map = L.Map.extend({ } this.initShortcuts() this.onceDataLoaded(function () { - if (L.Util.queryString('share')) this.share.open() - else if (this.options.onLoadPanel === 'databrowser') this.openBrowser() - else if (this.options.onLoadPanel === 'caption') this.displayCaption() - else if ( - this.options.onLoadPanel === 'facet' || - this.options.onLoadPanel === 'datafilters' - ) + if (L.Util.queryString('share')) { + this.share.open() + } else if (this.options.onLoadPanel === 'databrowser') { + this.openBrowser() + } else if (this.options.onLoadPanel === 'datalayers') { + this.ui.PANEL_MODE = 'condensed' + this.openBrowser() + } else if (this.options.onLoadPanel === 'caption') { + this.ui.PANEL_MODE = 'condensed' + this.displayCaption() + } else if (['facet', 'datafilters'].includes(this.options.onLoadPanel)) { this.openFacet() + } const slug = L.Util.queryString('feature') if (slug && this.features_index[slug]) this.features_index[slug].view() if (L.Util.queryString('edit')) { @@ -305,7 +310,7 @@ 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.datalayersControl = 'expanded' + options.onLoadPanel = 'datalayers' } }, @@ -1525,14 +1530,13 @@ U.Map = L.Map.extend({ const creditsBuilder = new U.FormBuilder(this, creditsFields) credits.appendChild(creditsBuilder.build()) this.ui.openPanel({ data: { html: container }, className: 'dark' }) - }, edit: function () { if (!this.editEnabled) return if (this.options.editMode !== 'advanced') return const container = L.DomUtil.create('div', 'umap-edit-container') - title = L.DomUtil.create('h3', '', container) + const title = L.DomUtil.create('h3', '', container) title.textContent = L._('Edit map properties') this._editControls(container) this._editShapeProperties(container) diff --git a/umap/static/umap/js/umap.ui.js b/umap/static/umap/js/umap.ui.js index 06f9d0dd..eccc32eb 100644 --- a/umap/static/umap/js/umap.ui.js +++ b/umap/static/umap/js/umap.ui.js @@ -5,6 +5,7 @@ U.UI = L.Evented.extend({ ALERTS: Array(), ALERT_ID: null, TOOLTIP_ID: null, + PANEL_MODE: 'expanded', initialize: function (parent) { this.parent = parent @@ -22,7 +23,7 @@ U.UI = L.Evented.extend({ }, resetPanelClassName: function () { - this._panel.className = 'with-transition' + this._panel.className = `with-transition ${this.PANEL_MODE}` }, openPanel: function (e) {