Skip to content

Commit

Permalink
Add Disable All and Enable All buttons for the Map Features list (close
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed May 22, 2019
1 parent 462b225 commit 35b3102
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
3 changes: 2 additions & 1 deletion css/80_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 22 additions & 0 deletions modules/renderer/features.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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]) {
Expand Down
39 changes: 35 additions & 4 deletions modules/ui/map_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 35b3102

Please sign in to comment.