diff --git a/js/id/graph/entity.js b/js/id/graph/entity.js index bce9675ee..bd402552e 100644 --- a/js/id/graph/entity.js +++ b/js/id/graph/entity.js @@ -9,22 +9,22 @@ iD.Entity = function(attrs) { return (new iD.Entity()).initialize(arguments); }; -iD.Entity.id = function (type) { +iD.Entity.id = function(type) { return iD.Entity.id.fromOSM(type, iD.Entity.id.next[type]--); }; iD.Entity.id.next = {node: -1, way: -1, relation: -1}; -iD.Entity.id.fromOSM = function (type, id) { +iD.Entity.id.fromOSM = function(type, id) { return type[0] + id; }; -iD.Entity.id.toOSM = function (id) { +iD.Entity.id.toOSM = function(id) { return id.slice(1); }; // A function suitable for use as the second argument to d3.selection#data(). -iD.Entity.key = function (entity) { +iD.Entity.key = function(entity) { return entity.id; }; @@ -84,7 +84,7 @@ iD.Entity.prototype = { }, hasInterestingTags: function() { - return _.keys(this.tags).some(function (key) { + return _.keys(this.tags).some(function(key) { return key != "attribution" && key != "created_by" && key != "source" && @@ -93,6 +93,23 @@ iD.Entity.prototype = { }); }, + deprecatedTags: function() { + var tags = _.pairs(this.tags); + var deprecated = {}; + + iD.data.deprecated.forEach(function(d) { + var match = _.pairs(d.old)[0]; + tags.forEach(function(t) { + if (t[0] == match[0] && + (t[1] == match[1] || match[1] == '*')) { + deprecated[t[0]] = t[1]; + } + }); + }); + + 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 ''; } diff --git a/js/id/ui/save.js b/js/id/ui/save.js index fc593c463..4e3bf883c 100644 --- a/js/id/ui/save.js +++ b/js/id/ui/save.js @@ -17,6 +17,7 @@ iD.ui.save = function(context) { d3.select('.shaded').remove(); var l = iD.ui.loading(t('uploading_changes'), true); + connection.putChangeset(history.changes(), e.comment, history.imagery_used(), function(err, changeset_id) { diff --git a/js/id/util.js b/js/id/util.js index 645d15363..9ebd4d761 100644 --- a/js/id/util.js +++ b/js/id/util.js @@ -8,8 +8,8 @@ iD.util.trueObj = function(arr) { iD.util.tagText = function(entity) { return d3.entries(entity.tags).map(function(e) { - return e.key + ': ' + e.value; - }).join('\n'); + return e.key + '=' + e.value; + }).join(', '); }; iD.util.stringQs = function(str) { diff --git a/js/id/validate.js b/js/id/validate.js index 6329b626f..dacff7889 100644 --- a/js/id/validate.js +++ b/js/id/validate.js @@ -29,6 +29,14 @@ iD.validate = function(changes, graph) { warnings.push({ message: t('validations.untagged_line'), entity: change }); } + var deprecatedTags = change.deprecatedTags(); + if (!_.isEmpty(deprecatedTags)) { + warnings.push({ + message: t('validations.deprecated_tags', { + tags: iD.util.tagText({ tags: deprecatedTags }) + }), entity: change }); + } + if (change.geometry(graph) === 'area' && _.isEmpty(change.tags)) { warnings.push({ message: t('validations.untagged_area'), entity: change }); } diff --git a/locale/en.js b/locale/en.js index 0fa3c1ea2..8f00590c6 100644 --- a/locale/en.js +++ b/locale/en.js @@ -127,7 +127,8 @@ locale.en = { untagged_point: "Untagged point which is not part of a line or area", untagged_line: "Untagged line", untagged_area: "Untagged area", - tag_suggests_area: "The tag {tag} suggests line should be area, but it is not an area" + tag_suggests_area: "The tag {tag} suggests line should be area, but it is not an area", + deprecated_tags: "Deprecated tags: {tags}" }, "save": "Save", diff --git a/test/spec/graph/entity.js b/test/spec/graph/entity.js index f2ac85f17..f0b7e0b19 100644 --- a/test/spec/graph/entity.js +++ b/test/spec/graph/entity.js @@ -114,6 +114,16 @@ describe('iD.Entity', function () { }); }); + describe("#hasDeprecatedTags", function () { + it("returns false if entity has no tags", function () { + expect(iD.Entity().deprecatedTags()).to.eql({}); + }); + + it("returns true if entity has deprecated tags", function () { + expect(iD.Entity({ tags: { barrier: 'wire_fence' } }).deprecatedTags()).to.eql({ barrier: 'wire_fence' }); + }); + }); + describe("#hasInterestingTags", function () { it("returns false if the entity has no tags", function () { expect(iD.Entity().hasInterestingTags()).to.equal(false); diff --git a/test/spec/util.js b/test/spec/util.js index de3fab735..d866a7b39 100644 --- a/test/spec/util.js +++ b/test/spec/util.js @@ -6,8 +6,8 @@ describe('iD.Util', function() { it('.tagText', function() { expect(iD.util.tagText({})).to.eql(''); - expect(iD.util.tagText({tags:{foo:'bar'}})).to.eql('foo: bar'); - expect(iD.util.tagText({tags:{foo:'bar',two:'three'}})).to.eql('foo: bar\ntwo: three'); + expect(iD.util.tagText({tags:{foo:'bar'}})).to.eql('foo=bar'); + expect(iD.util.tagText({tags:{foo:'bar',two:'three'}})).to.eql('foo=bar, two=three'); }); it('.stringQs', function() {