diff --git a/index.html b/index.html index 0e70233cc..640dfa51a 100644 --- a/index.html +++ b/index.html @@ -55,6 +55,7 @@ + diff --git a/js/id/actions/split_way.js b/js/id/actions/split_way.js new file mode 100644 index 000000000..4b4152a99 --- /dev/null +++ b/js/id/actions/split_way.js @@ -0,0 +1,7 @@ +// https://github.com/systemed/potlatch2/blob/master/net/systemeD/halcyon/connection/actions/SplitWayAction.as +iD.actions.SplitWay = function(nodeId, wayId) { + return function(graph) { + var way = graph.entity(wayId); + return graph.replace(way.update({nodes: nodes}), 'changed way direction'); + }; +}; diff --git a/js/id/modes/draw_road.js b/js/id/modes/draw_road.js index 769c4412c..2a69be178 100644 --- a/js/id/modes/draw_road.js +++ b/js/id/modes/draw_road.js @@ -38,6 +38,12 @@ iD.modes.DrawRoad = function(wayId, direction) { controller.enter(iD.modes.Select(way)); + } else if (datum.id === headId) { + // finish the way + history.replace(iD.actions.DeleteNode(node.id)); + + controller.enter(iD.modes.Select(way)); + } else if (datum.type === 'node' && datum.id !== node.id) { // connect the way to an existing node history.replace( diff --git a/js/id/ui/inspector.js b/js/id/ui/inspector.js index 60a84819a..f24a4b56d 100644 --- a/js/id/ui/inspector.js +++ b/js/id/ui/inspector.js @@ -32,9 +32,16 @@ iD.Inspector = function() { .attr('href', '#') .text('Reverse Direction') .on('click', function(d) { - event.changeWayDirection(iD.Entity(d, { - nodes: _.pluck(d.nodes.reverse(), 'id') - })); + event.changeWayDirection(iD.Entity(d)); + }); + } + if (selection.datum().type === 'node' && !selection.datum()._poi) { + selection.append('a') + .attr('class', 'permalink') + .attr('href', '#') + .text('Split Way') + .on('click', function(d) { + event.splitWay(iD.Entity(d)); }); } }