From 35b3102006f3fe931589c8221faa652e5aadd439 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 22 May 2019 11:56:04 -0400 Subject: [PATCH] Add Disable All and Enable All buttons for the Map Features list (close #5234) --- css/80_app.css | 3 ++- modules/renderer/features.js | 22 ++++++++++++++++++++ modules/ui/map_data.js | 39 ++++++++++++++++++++++++++++++++---- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/css/80_app.css b/css/80_app.css index 1eceb6b637..f0b1a05184 100644 --- a/css/80_app.css +++ b/css/80_app.css @@ -3384,7 +3384,8 @@ button.autofix.action.active { } .layer-list.issue-rules-list, -.layer-list.issues-list { +.layer-list.issues-list, +.layer-list.layer-feature-list { margin-bottom: 0; } .section-footer { diff --git a/modules/renderer/features.js b/modules/renderer/features.js index 0004454c4d..b99e2a05da 100644 --- a/modules/renderer/features.js +++ b/modules/renderer/features.js @@ -274,6 +274,17 @@ export function rendererFeatures(context) { } }; + features.enableAll = function() { + var didEnable = false; + for (var k in _rules) { + if (!_rules[k].enabled) { + didEnable = true; + _rules[k].enable(); + } + } + if (didEnable) update(); + }; + features.disable = function(k) { if (_rules[k] && _rules[k].enabled) { @@ -282,6 +293,17 @@ export function rendererFeatures(context) { } }; + features.disableAll = function() { + var didDisable = false; + for (var k in _rules) { + if (_rules[k].enabled) { + didDisable = true; + _rules[k].disable(); + } + } + if (didDisable) update(); + }; + features.toggle = function(k) { if (_rules[k]) { diff --git a/modules/ui/map_data.js b/modules/ui/map_data.js index 3dbc1c7cd1..d0b8475ac3 100644 --- a/modules/ui/map_data.js +++ b/modules/ui/map_data.js @@ -662,13 +662,44 @@ export function uiMapData(context) { function renderFeatureList(selection) { - var container = selection.selectAll('.layer-feature-list') + var container = selection.selectAll('.layer-feature-list-container') .data([0]); - _featureList = container.enter() + var containerEnter = container.enter() + .append('div') + .attr('class', 'layer-feature-list-container'); + + containerEnter .append('ul') - .attr('class', 'layer-list layer-feature-list') - .merge(container); + .attr('class', 'layer-list layer-feature-list'); + + var footer = containerEnter + .append('div') + .attr('class', 'feature-list-links section-footer'); + + footer + .append('a') + .attr('class', 'feature-list-link') + .attr('href', '#') + .text(t('issues.enable_all')) + .on('click', function() { + context.features().enableAll(); + }); + + footer + .append('a') + .attr('class', 'feature-list-link') + .attr('href', '#') + .text(t('issues.disable_all')) + .on('click', function() { + context.features().disableAll(); + }); + + // Update + container = container + .merge(containerEnter); + + _featureList = container.selectAll('.layer-feature-list'); updateFeatureList(); }