Force visible any entities related to a selected error

(closes #5880)
This commit is contained in:
Bryan Housel
2019-02-10 23:29:23 -05:00
parent 6e45796be7
commit ba44c80076
5 changed files with 106 additions and 71 deletions
+2 -1
View File
@@ -148,8 +148,9 @@ export function modeSelectError(context, selectedErrorID, selectedErrorService)
.hide();
context.selectedErrorID(null);
context.features().forceVisible([]);
};
return mode;
}
}
+26 -17
View File
@@ -8,10 +8,7 @@ import { dispatch as d3_dispatch } from 'd3-dispatch';
import { osmEntity } from '../osm';
import { utilRebind } from '../util/rebind';
import {
utilQsString,
utilStringQs
} from '../util';
import { utilQsString, utilStringQs } from '../util';
export function rendererFeatures(context) {
@@ -58,13 +55,14 @@ export function rendererFeatures(context) {
'obliterated': true
};
var dispatch = d3_dispatch('change', 'redraw'),
_cullFactor = 1,
_cache = {},
_features = {},
_stats = {},
_keys = [],
_hidden = [];
var dispatch = d3_dispatch('change', 'redraw');
var _cullFactor = 1;
var _cache = {};
var _features = {};
var _stats = {};
var _keys = [];
var _hidden = [];
var _forceVisible = {};
function update() {
@@ -277,10 +275,10 @@ export function rendererFeatures(context) {
features.gatherStats = function(d, resolver, dimensions) {
var needsRedraw = false,
type = _groupBy(d, function(ent) { return ent.type; }),
entities = [].concat(type.relation || [], type.way || [], type.node || []),
currHidden, geometry, matches, i, j;
var needsRedraw = false;
var type = _groupBy(d, function(ent) { return ent.type; });
var entities = [].concat(type.relation || [], type.way || [], type.node || []);
var currHidden, geometry, matches, i, j;
for (i = 0; i < _keys.length; i++) {
_features[_keys[i]].count = 0;
@@ -346,8 +344,8 @@ export function rendererFeatures(context) {
}
if (!_cache[ent].matches) {
var matches = {},
hasMatch = false;
var matches = {};
var hasMatch = false;
for (var i = 0; i < _keys.length; i++) {
if (_keys[i] === 'others') {
@@ -462,6 +460,7 @@ export function rendererFeatures(context) {
features.isHidden = function(entity, resolver, geometry) {
if (!_hidden.length) return false;
if (!entity.version) return false;
if (_forceVisible[entity.id]) return false;
var fn = (geometry === 'vertex' ? features.isHiddenChild : features.isHiddenFeature);
return fn(entity, resolver, geometry);
@@ -482,6 +481,16 @@ export function rendererFeatures(context) {
};
features.forceVisible = function(entityIDs) {
if (!arguments.length) return Object.keys(_forceVisible);
_forceVisible = {};
for (var i = 0; i < entityIDs.length; i++) {
_forceVisible[entityIDs[i]] = true;
}
return features;
};
features.init = function() {
var storage = context.storage('disabled-features');
if (storage) {
+7 -1
View File
@@ -64,6 +64,7 @@ export function uiImproveOsmDetails(context) {
.html(errorDetail);
// If there are entity links in the error message..
var relatedEntities = [];
descriptionEnter.selectAll('.error_entity_link, .error_object_link')
.each(function() {
var link = d3_select(this);
@@ -73,6 +74,8 @@ export function uiImproveOsmDetails(context) {
: this.textContent;
var entity = context.hasEntity(entityID);
relatedEntities.push(entityID);
// Add click handler
link
.on('mouseover', function() {
@@ -116,6 +119,9 @@ export function uiImproveOsmDetails(context) {
}
}
});
// Don't hide entities related to this error - #5880
context.features().forceVisible(relatedEntities);
}
@@ -127,4 +133,4 @@ export function uiImproveOsmDetails(context) {
return improveOsmDetails;
}
}
+6
View File
@@ -66,6 +66,7 @@ export function uiKeepRightDetails(context) {
.html(errorDetail);
// If there are entity links in the error message..
var relatedEntities = [];
descriptionEnter.selectAll('.error_entity_link, .error_object_link')
.each(function() {
var link = d3_select(this);
@@ -75,6 +76,8 @@ export function uiKeepRightDetails(context) {
: this.textContent;
var entity = context.hasEntity(entityID);
relatedEntities.push(entityID);
// Add click handler
link
.on('mouseover', function() {
@@ -118,6 +121,9 @@ export function uiKeepRightDetails(context) {
}
}
});
// Don't hide entities related to this error - #5880
context.features().forceVisible(relatedEntities);
}