From 71000547077780dbefb4bf467174469ed6daca37 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Sat, 30 Mar 2013 14:17:18 -0700 Subject: [PATCH] Use preset names in commit dialog --- js/id/core/entity.js | 22 ---------------------- js/id/ui/commit.js | 5 +++-- test/spec/core/entity.js | 14 -------------- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/js/id/core/entity.js b/js/id/core/entity.js index a71f1a8ed..71ac7c5cb 100644 --- a/js/id/core/entity.js +++ b/js/id/core/entity.js @@ -116,27 +116,5 @@ iD.Entity.prototype = { }); return deprecated; - }, - - friendlyName: function() { - // Generate a string such as 'river' or 'Fred's House' for an entity. - if (!this.tags || !Object.keys(this.tags).length) { return ''; } - - var mainkeys = ['highway', 'amenity', 'railway', 'waterway', 'natural'], - n = []; - - if (this.tags.name) n.push(this.tags.name); - if (this.tags.ref) n.push(this.tags.ref); - - if (!n.length) { - for (var k in this.tags) { - if (mainkeys.indexOf(k) !== -1) { - n.push(this.tags[k]); - break; - } - } - } - - return n.length === 0 ? 'unknown' : n.join('; '); } }; diff --git a/js/id/ui/commit.js b/js/id/ui/commit.js index 324ce192f..76255bcf1 100644 --- a/js/id/ui/commit.js +++ b/js/id/ui/commit.js @@ -1,11 +1,12 @@ iD.ui.Commit = function(context) { - var event = d3.dispatch('cancel', 'save', 'fix'); + var event = d3.dispatch('cancel', 'save', 'fix'), + presets = context.presets(); function zipSame(d) { var c = [], n = -1; for (var i = 0; i < d.length; i++) { var desc = { - name: d[i].friendlyName(), + name: d[i].tags.name || presets.match(d[i], context.graph()).name(), type: d[i].type, count: 1, tagText: iD.util.tagText(d[i]) diff --git a/test/spec/core/entity.js b/test/spec/core/entity.js index b1ea3d308..8ab310f5d 100644 --- a/test/spec/core/entity.js +++ b/test/spec/core/entity.js @@ -163,18 +163,4 @@ describe('iD.Entity', function () { expect(iD.Entity({tags: {'tiger:source': 'blah', 'tiger:foo': 'bar'}}).hasInterestingTags()).to.equal(false); }); }); - - describe("#friendlyName", function () { - it("returns the name", function () { - expect(iD.Entity({ tags: { name: 'hi' }}).friendlyName()).to.equal('hi'); - }); - - it("returns a highway tag value", function () { - expect(iD.Entity({ tags: { highway: 'Route 5' }}).friendlyName()).to.equal('Route 5'); - }); - - it("prefers the name to a highway tag value", function () { - expect(iD.Entity({ tags: { name: 'hi', highway: 'Route 5' }}).friendlyName()).to.equal('hi'); - }); - }); });