Use preset names in commit dialog

This commit is contained in:
John Firebaugh
2013-03-30 14:17:18 -07:00
parent 0f59434645
commit 7100054707
3 changed files with 3 additions and 38 deletions
-22
View File
@@ -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('; ');
}
};
+3 -2
View File
@@ -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])
-14
View File
@@ -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');
});
});
});