Preserve selected entity when cancelling save mode

(closes #4407)
This commit is contained in:
Bryan Housel
2017-11-12 12:34:04 -05:00
parent 2f81cd6729
commit 35a9f77a63
3 changed files with 30 additions and 10 deletions
+11 -3
View File
@@ -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));
}
}
+2 -1
View File
@@ -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')
+17 -6
View File
@@ -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;
}