From 4dd4ccb205415d07a27dd94986a90ae6265d8982 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sat, 16 Apr 2016 23:17:04 -0400 Subject: [PATCH] Dedupe relations with same calculated name so d3.combobox will show them (closes #2891) --- js/id/ui/raw_membership_editor.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/id/ui/raw_membership_editor.js b/js/id/ui/raw_membership_editor.js index a1a57d27d..2ca442552 100644 --- a/js/id/ui/raw_membership_editor.js +++ b/js/id/ui/raw_membership_editor.js @@ -67,6 +67,19 @@ iD.ui.RawMembershipEditor = function(context) { result.sort(function(a, b) { return iD.Relation.creationOrder(a.relation, b.relation); }); + + // Dedupe identical names by appending relation id - see #2891 + var dupeGroups = _(result) + .groupBy('value') + .filter(function(v) { return v.length > 1; }) + .value(); + + dupeGroups.forEach(function(group) { + group.forEach(function(obj) { + obj.value += ' ' + obj.relation.id; + }); + }); + result.unshift(newRelation); return result;