diff --git a/js/id/actions/delete_way.js b/js/id/actions/delete_way.js index 157a190a7..ae5fe27a8 100644 --- a/js/id/actions/delete_way.js +++ b/js/id/actions/delete_way.js @@ -12,7 +12,11 @@ iD.actions.DeleteWay = function(way) { graph = iD.actions.removeWayNode(way, node)(graph); if (!graph.parentWays(id).length && !graph.parentRelations(id).length) { - graph = graph.remove(node); + if (!node.hasInterestingTags()) { + graph = graph.remove(node); + } else { + graph = graph.replace(node.update({_poi: true})); + } } }); diff --git a/js/id/graph/entity.js b/js/id/graph/entity.js index a10da5d3a..2159cab47 100644 --- a/js/id/graph/entity.js +++ b/js/id/graph/entity.js @@ -29,6 +29,12 @@ iD.Entity.prototype = { modified: function() { return this._updated && +this.id.slice(1) > 0; + }, + + hasInterestingTags: function() { + return _.keys(this.tags).some(function (key) { + return key != "attribution" && key != "created_by" && key != "source" && key != 'odbl' && key.indexOf('tiger:') != 0; + }); } }; diff --git a/test/spec/actions/delete_way.js b/test/spec/actions/delete_way.js index ed86e45a0..0323b75ee 100644 --- a/test/spec/actions/delete_way.js +++ b/test/spec/actions/delete_way.js @@ -31,6 +31,19 @@ describe("iD.actions.DeleteWay", function () { expect(graph.entity(node.id)).not.to.be.undefined; }); - it("does not delete member nodes with interesting tags"); - it("registers member nodes with interesting tags as POIs"); + it("does not delete member nodes with interesting tags", function () { + var node = iD.Node({tags: {highway: 'traffic_signals'}}), + way = iD.Way({nodes: [node.id]}), + action = iD.actions.DeleteWay(way), + graph = action(iD.Graph([node, way])); + expect(graph.entity(node.id)).not.to.be.undefined; + }); + + it("registers member nodes with interesting tags as POIs", function () { + var node = iD.Node({tags: {highway: 'traffic_signals'}}), + way = iD.Way({nodes: [node.id]}), + action = iD.actions.DeleteWay(way), + graph = action(iD.Graph([node, way])); + expect(graph.entity(node.id)._poi).to.be.ok; + }); }); diff --git a/test/spec/graph/entity.js b/test/spec/graph/entity.js index e28c782ef..71954b73a 100644 --- a/test/spec/graph/entity.js +++ b/test/spec/graph/entity.js @@ -61,6 +61,24 @@ describe('Entity', function () { expect(iD.Entity({id: 'w-1234'}).update({}).modified()).not.to.be.ok; }); }); + + describe("#hasInterestingTags", function () { + it("returns false if the entity has no tags", function () { + expect(iD.Entity().hasInterestingTags()).to.equal(false); + }); + + it("returns true if the entity has tags other than 'attribution', 'created_by', 'source', 'odbl' and tiger tags", function () { + expect(iD.Entity({tags: {foo: 'bar'}}).hasInterestingTags()).to.equal(true); + }); + + it("return false if the entity has only uninteresting tags", function () { + expect(iD.Entity({tags: {source: 'Bing'}}).hasInterestingTags()).to.equal(false); + }); + + it("return false if the entity has only tiger tags", function () { + expect(iD.Entity({tags: {'tiger:source': 'blah', 'tiger:foo': 'bar'}}).hasInterestingTags()).to.equal(false); + }); + }); }); describe('Node', function () {