mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 13:18:15 +02:00
Use preset names in commit dialog
This commit is contained in:
@@ -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
@@ -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])
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user