diff --git a/modules/modes/save.js b/modules/modes/save.js index 18a01ea9b..4fb3908a0 100644 --- a/modules/modes/save.js +++ b/modules/modes/save.js @@ -24,7 +24,11 @@ import { } from '../actions'; import { coreGraph } from '../core'; -import { modeBrowse } from './index'; + +import { + modeBrowse, + modeSelect +} from './index'; import { uiConflicts, @@ -53,8 +57,12 @@ export function modeSave(context) { .on('save', save); - function cancel() { - context.enter(modeBrowse(context)); + function cancel(selectedID) { + if (selectedID) { + context.enter(modeSelect(context, [selectedID])); + } else { + context.enter(modeBrowse(context)); + } } diff --git a/modules/ui/commit.js b/modules/ui/commit.js index 62ca53989..52696ca30 100644 --- a/modules/ui/commit.js +++ b/modules/ui/commit.js @@ -228,7 +228,8 @@ export function uiCommit(context) { buttonSection.selectAll('.cancel-button') .on('click.cancel', function() { - dispatch.call('cancel'); + var selectedID = commitChanges.entityID(); + dispatch.call('cancel', this, selectedID); }); buttonSection.selectAll('.save-button') diff --git a/modules/ui/commit_changes.js b/modules/ui/commit_changes.js index 321d643bc..195a7fd6c 100644 --- a/modules/ui/commit_changes.js +++ b/modules/ui/commit_changes.js @@ -15,6 +15,7 @@ import { export function uiCommitChanges(context) { + var _entityID; var detected = utilDetect(); @@ -91,7 +92,7 @@ export function uiCommitChanges(context) { items .on('mouseover', mouseover) .on('mouseout', mouseout) - .on('click', zoomToEntity); + .on('click', click); // Download changeset link @@ -144,17 +145,27 @@ export function uiCommitChanges(context) { } - function zoomToEntity(change) { - var entity = change.entity; - if (change.changeType !== 'deleted' && - context.graph().entity(entity.id).geometry(context.graph()) !== 'vertex') { + function click(change) { + if (change.changeType === 'deleted') { + _entityID = null; + } else { + var entity = change.entity; + _entityID = change.entity.id; context.map().zoomTo(entity); - context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())) + context.surface().selectAll(utilEntityOrMemberSelector([_entityID], context.graph())) .classed('hover', true); } } } + commitChanges.entityID = function(_) { + if (!arguments.length) return _entityID; + _entityID = _; + return commitChanges; + }; + + + return commitChanges; }