DrawWay#cancel shouldn't unconditionally delete the way

Fixes #514.
This commit is contained in:
John Firebaugh
2013-01-28 16:38:54 -05:00
parent 7ffda8c7d3
commit 859ae1c1cc
5 changed files with 24 additions and 19 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
iD.behavior.DrawWay = function(wayId, headId, tailId, index, mode) {
iD.behavior.DrawWay = function(wayId, headId, tailId, index, mode, baseGraph) {
var map = mode.map,
history = mode.history,
controller = mode.controller,
@@ -129,7 +129,7 @@ iD.behavior.DrawWay = function(wayId, headId, tailId, index, mode) {
// Cancel the draw operation and return to browse, deleting everything drawn.
drawWay.cancel = function() {
history.perform(iD.actions.DeleteWay(wayId), 'cancelled drawing');
history.perform(d3.functor(baseGraph), 'cancelled drawing');
controller.enter(iD.modes.Browse());
};
+9 -6
View File
@@ -16,18 +16,20 @@ iD.modes.AddArea = function() {
controller = mode.controller;
function startFromNode(node) {
var way = iD.Way({tags: defaultTags});
var graph = history.graph(),
way = iD.Way({tags: defaultTags});
history.perform(
iD.actions.AddWay(way),
iD.actions.AddWayNode(way.id, node.id),
iD.actions.AddWayNode(way.id, node.id));
controller.enter(iD.modes.DrawArea(way.id));
controller.enter(iD.modes.DrawArea(way.id, graph));
}
function startFromWay(other, loc, index) {
var node = iD.Node({loc: loc}),
var graph = history.graph(),
node = iD.Node({loc: loc}),
way = iD.Way({tags: defaultTags});
history.perform(
@@ -37,11 +39,12 @@ iD.modes.AddArea = function() {
iD.actions.AddWayNode(way.id, node.id),
iD.actions.AddWayNode(other.id, node.id, index));
controller.enter(iD.modes.DrawArea(way.id));
controller.enter(iD.modes.DrawArea(way.id, graph));
}
function start(loc) {
var node = iD.Node({loc: loc}),
var graph = history.graph(),
node = iD.Node({loc: loc}),
way = iD.Way({tags: defaultTags});
history.perform(
@@ -50,7 +53,7 @@ iD.modes.AddArea = function() {
iD.actions.AddWayNode(way.id, node.id),
iD.actions.AddWayNode(way.id, node.id));
controller.enter(iD.modes.DrawArea(way.id));
controller.enter(iD.modes.DrawArea(way.id, graph));
}
behavior = iD.behavior.AddWay(mode)
+9 -7
View File
@@ -21,10 +21,10 @@ iD.modes.AddLine = function() {
isLine = parent && parent.geometry(graph) === 'line';
if (isLine && parent.first() === node.id) {
controller.enter(iD.modes.DrawLine(parent.id, 'backward'));
controller.enter(iD.modes.DrawLine(parent.id, 'backward', graph));
} else if (isLine && parent.last() === node.id) {
controller.enter(iD.modes.DrawLine(parent.id, 'forward'));
controller.enter(iD.modes.DrawLine(parent.id, 'forward', graph));
} else {
var way = iD.Way({tags: defaultTags});
@@ -33,12 +33,13 @@ iD.modes.AddLine = function() {
iD.actions.AddWay(way),
iD.actions.AddWayNode(way.id, node.id));
controller.enter(iD.modes.DrawLine(way.id, 'forward'));
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
}
}
function startFromWay(other, loc, index) {
var node = iD.Node({loc: loc}),
var graph = history.graph(),
node = iD.Node({loc: loc}),
way = iD.Way({tags: defaultTags});
history.perform(
@@ -47,11 +48,12 @@ iD.modes.AddLine = function() {
iD.actions.AddWayNode(way.id, node.id),
iD.actions.AddWayNode(other.id, node.id, index));
controller.enter(iD.modes.DrawLine(way.id, 'forward'));
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
}
function start(loc) {
var node = iD.Node({loc: loc}),
var graph = history.graph(),
node = iD.Node({loc: loc}),
way = iD.Way({tags: defaultTags});
history.perform(
@@ -59,7 +61,7 @@ iD.modes.AddLine = function() {
iD.actions.AddWay(way),
iD.actions.AddWayNode(way.id, node.id));
controller.enter(iD.modes.DrawLine(way.id, 'forward'));
controller.enter(iD.modes.DrawLine(way.id, 'forward', graph));
}
behavior = iD.behavior.AddWay(mode)
+2 -2
View File
@@ -1,4 +1,4 @@
iD.modes.DrawArea = function(wayId) {
iD.modes.DrawArea = function(wayId, baseGraph) {
var mode = {
button: 'area',
id: 'draw-area'
@@ -29,7 +29,7 @@ iD.modes.DrawArea = function(wayId) {
behavior.add(loc, annotation);
}
behavior = iD.behavior.DrawWay(wayId, headId, tailId, index, mode)
behavior = iD.behavior.DrawWay(wayId, headId, tailId, index, mode, baseGraph)
.on('addHead', addHeadTail)
.on('addTail', addHeadTail)
.on('addNode', addNode)
+2 -2
View File
@@ -1,4 +1,4 @@
iD.modes.DrawLine = function(wayId, direction) {
iD.modes.DrawLine = function(wayId, direction, baseGraph) {
var mode = {
button: 'line',
id: 'draw-line'
@@ -38,7 +38,7 @@ iD.modes.DrawLine = function(wayId, direction) {
behavior.add(loc, annotation);
}
behavior = iD.behavior.DrawWay(wayId, headId, tailId, index, mode)
behavior = iD.behavior.DrawWay(wayId, headId, tailId, index, mode, baseGraph)
.on('addHead', addHead)
.on('addTail', addTail)
.on('addNode', addNode)