From a160c00c35e02462a4f91ed77f7e7d01365d7977 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 27 Mar 2018 23:54:26 -0400 Subject: [PATCH] Hide Turn Restriction field on trivial junctions (closes #4934) --- modules/ui/fields/restrictions.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/ui/fields/restrictions.js b/modules/ui/fields/restrictions.js index 0905d5b1e..23e3e0f5e 100644 --- a/modules/ui/fields/restrictions.js +++ b/modules/ui/fields/restrictions.js @@ -79,7 +79,17 @@ export function uiFieldRestrictions(field, context) { // It's possible for there to be no actual intersection here. // for example, a vertex of two `highway=path` // In this case, hide the field. - var isOK = (_intersection && _intersection.vertices.length && _intersection.ways.length); + var isOK = ( + _intersection && + _intersection.vertices.length && // has vertices + _intersection.vertices // has the vertex that the user selected + .filter(function(vertex) { return vertex.id === _vertexID; }).length && + _intersection.ways.length > 2 && // has more than 2 ways + _intersection.ways // has more than 1 TO way + .filter(function(way) { return way.__to; }).length > 1 + ); + + // Also hide in the case where d3_select(selection.node().parentNode).classed('hide', !isOK); // if form field is hidden or has detached from dom, clean up.