Files
iD/modules/ui/entity_highlight.js
T
Quincy Morgan 81feb1cd99 Adds hover-highlighting for relations in the raw membership list
Moves hover-highlighting behavior to its own function
Hover-highlighting now correctly highlights all members of the target relation
2018-10-24 22:17:28 -07:00

18 lines
686 B
JavaScript

import _forEach from 'lodash-es/forEach';
export function highlightEntity(context, entity, highlighted) {
// highlight the member feature in the map while hovering on the list item
var selectorPrefix = entity.type === 'node' ? 'g.' : 'path.';
context.surface().selectAll(selectorPrefix+entity.id).classed('highlighted', highlighted);
if (entity.members) {
// recursively highlight members so that relations will appear highlighted
_forEach(entity.members, function(member){
if (member.id && context.hasEntity(member.id)) {
highlightEntity(context, context.entity(member.id), highlighted);
}
});
}
}