Show filters menu only if filter keys are defined

This commit is contained in:
3st3ban3 2023-02-18 10:13:12 +01:00
parent ce17f8dfe0
commit 6d900ac79f

View file

@ -964,12 +964,16 @@ L.U.Map.include({
var labelBrowser = L.DomUtil.create('span', '', browser); var labelBrowser = L.DomUtil.create('span', '', browser);
labelBrowser.textContent = labelBrowser.title = L._('Browse data'); labelBrowser.textContent = labelBrowser.title = L._('Browse data');
L.DomEvent.on(browser, 'click', this.openBrowser, this); L.DomEvent.on(browser, 'click', this.openBrowser, this);
var filter = L.DomUtil.create('li', ''); var actions = [browser];
L.DomUtil.create('i', 'umap-icon-16 umap-add', filter); if (this.options.advancedFilterKey) {
var labelFilter = L.DomUtil.create('span', '', filter); var filter = L.DomUtil.create('li', '');
labelFilter.textContent = labelFilter.title = L._('Filter data'); L.DomUtil.create('i', 'umap-icon-16 umap-add', filter);
L.DomEvent.on(filter, 'click', this.openFilter, this); var labelFilter = L.DomUtil.create('span', '', filter);
this.ui.openPanel({data: {html: container}, actions: [browser, filter]}); labelFilter.textContent = labelFilter.title = L._('Filter data');
L.DomEvent.on(filter, 'click', this.openFilter, this);
actions.push(filter)
}
this.ui.openPanel({data: {html: container}, actions: actions});
}, },
eachDataLayer: function (method, context) { eachDataLayer: function (method, context) {
@ -1285,6 +1289,7 @@ L.U.Map.include({
builder = new L.U.FormBuilder(this, optionsFields, { builder = new L.U.FormBuilder(this, optionsFields, {
callback: function (e) { callback: function (e) {
this.initCaptionBar();
this.eachDataLayer(function (datalayer) { this.eachDataLayer(function (datalayer) {
if (e.helper.field === 'options.sortKey') datalayer.reindex(); if (e.helper.field === 'options.sortKey') datalayer.reindex();
datalayer.redraw(); datalayer.redraw();
@ -1465,10 +1470,12 @@ L.U.Map.include({
browser.href = '#'; browser.href = '#';
L.DomEvent.on(browser, 'click', L.DomEvent.stop) L.DomEvent.on(browser, 'click', L.DomEvent.stop)
.on(browser, 'click', this.openBrowser, this); .on(browser, 'click', this.openBrowser, this);
var filter = L.DomUtil.add('a', 'umap-open-filter-link', container, ' | ' + L._('Filter data')); if (this.options.advancedFilterKey) {
filter.href = '#'; var filter = L.DomUtil.add('a', 'umap-open-filter-link', container, ' | ' + L._('Filter data'));
L.DomEvent.on(filter, 'click', L.DomEvent.stop) filter.href = '#';
.on(filter, 'click', this.openFilter, this); L.DomEvent.on(filter, 'click', L.DomEvent.stop)
.on(filter, 'click', this.openFilter, this);
}
} }
var setName = function () { var setName = function () {
name.textContent = this.getDisplayName(); name.textContent = this.getDisplayName();
@ -1650,15 +1657,17 @@ L.U.Map.include({
}); });
} }
} }
items.push('-', items.push('-', {
{ text: L._('Browse data'),
text: L._('Browse data'), callback: this.openBrowser
callback: this.openBrowser });
}, if (this.options.advancedFilterKey) {
{ items.push({
text: L._('Filter data'), text: L._('Filter data'),
callback: this.openFilter callback: this.openFilter
}, })
}
items.push(
{ {
text: L._('About'), text: L._('About'),
callback: this.displayCaption callback: this.displayCaption