Files
iD/js/id/actions/delete_node.js
John Firebaugh 69d95a6082 Refactor operations
They're something distinct from actions. Actions are independent
of UI, operations are actions + UI (title, keybinding, modality,
etc.)
2013-01-29 12:05:52 -05:00

24 lines
757 B
JavaScript

// https://github.com/openstreetmap/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/DeleteNodeAction.as
iD.actions.DeleteNode = function(nodeId) {
return function(graph) {
var node = graph.entity(nodeId);
graph.parentWays(node)
.forEach(function(parent) {
parent = parent.removeNode(nodeId);
graph = graph.replace(parent);
if (parent.isDegenerate()) {
graph = iD.actions.DeleteWay(parent.id)(graph);
}
});
graph.parentRelations(node)
.forEach(function(parent) {
graph = graph.replace(parent.removeMember(nodeId));
});
return graph.remove(node);
};
};