mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Delete ways and areas when they are down to one and two nodes
This commit is contained in:
@@ -8,7 +8,9 @@ iD.modes.DrawArea = function(wayId) {
|
||||
history = mode.history,
|
||||
controller = mode.controller,
|
||||
way = history.graph().entity(wayId),
|
||||
headId = _.last(way.nodes),
|
||||
headId = (way.nodes.length == 1) ?
|
||||
way.nodes[0] :
|
||||
way.nodes[way.nodes.length - 2],
|
||||
tailId = _.first(way.nodes),
|
||||
node = iD.Node({loc: map.mouseCoordinates()});
|
||||
|
||||
@@ -68,7 +70,14 @@ iD.modes.DrawArea = function(wayId) {
|
||||
iD.actions.DeleteNode(node.id),
|
||||
iD.actions.DeleteNode(headId));
|
||||
|
||||
controller.enter(iD.modes.DrawArea(wayId));
|
||||
if (history.graph().fetch(wayId).nodes.length === 2) {
|
||||
history.replace(
|
||||
iD.actions.DeleteNode(way.nodes[0]),
|
||||
iD.actions.DeleteWay(wayId));
|
||||
controller.enter(iD.modes.Browse());
|
||||
} else {
|
||||
controller.enter(iD.modes.DrawArea(wayId));
|
||||
}
|
||||
}
|
||||
|
||||
map.surface.on('mousemove.drawarea', mousemove);
|
||||
|
||||
@@ -74,22 +74,30 @@ iD.modes.DrawRoad = function(wayId, direction) {
|
||||
}
|
||||
});
|
||||
|
||||
map.keybinding().on('⎋.drawroad', function() {
|
||||
function esc() {
|
||||
history.replace(
|
||||
iD.actions.DeleteNode(node.id));
|
||||
|
||||
controller.enter(iD.modes.Browse());
|
||||
});
|
||||
}
|
||||
|
||||
map.keybinding().on('⌫.drawroad', function() {
|
||||
function del() {
|
||||
d3.event.preventDefault();
|
||||
|
||||
history.replace(
|
||||
iD.actions.DeleteNode(node.id),
|
||||
iD.actions.DeleteNode(headId));
|
||||
|
||||
controller.enter(iD.modes.DrawRoad(wayId, direction));
|
||||
});
|
||||
if (history.graph().fetch(wayId).nodes.length === 0) {
|
||||
history.replace(iD.actions.DeleteWay(wayId));
|
||||
controller.enter(iD.modes.Browse());
|
||||
} else {
|
||||
controller.enter(iD.modes.DrawRoad(wayId, direction));
|
||||
}
|
||||
}
|
||||
|
||||
map.keybinding().on('⎋.drawroad', esc);
|
||||
map.keybinding().on('⌫.drawroad', del);
|
||||
};
|
||||
|
||||
mode.exit = function() {
|
||||
|
||||
Reference in New Issue
Block a user