mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Finish iD.actions.DeleteWay (fixes #72)
This commit is contained in:
@@ -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}));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user