Make the extract operation a single step instead of immediately entering modeMove (close #6674)

This commit is contained in:
Quincy Morgan
2020-05-13 10:58:53 -04:00
parent b0a9b8d730
commit 04bdc4da1c
3 changed files with 9 additions and 33 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
import { geoPath as d3_geoPath } from 'd3-geo';
import { geoCentroid as d3_geoCentroid } from 'd3-geo';
import { osmNode } from '../osm/node';
export function actionExtract(entityID, projection) {
export function actionExtract(entityID) {
var extractedNodeID;
@@ -43,7 +43,7 @@ export function actionExtract(entityID, projection) {
var keysToRetain = ['area', 'type'];
var buildingKeysToRetain = ['architect', 'building', 'height', 'layer'];
var centroid = d3_geoPath(projection).centroid(entity.asGeoJSON(graph, true));
var centroid = d3_geoCentroid(entity.asGeoJSON(graph));
var isBuilding = entity.tags.building;
+4 -28
View File
@@ -1,44 +1,20 @@
import { actionExtract } from '../actions/extract';
import { actionMoveNode } from '../actions/move_node';
import { behaviorOperation } from '../behavior/operation';
import { modeMove } from '../modes/move';
import { modeSelect } from '../modes/select';
import { t } from '../core/localizer';
import { presetManager } from '../presets';
export function operationExtract(selectedIDs, context) {
var entityID = selectedIDs.length && selectedIDs[0];
var action = actionExtract(entityID, context.projection);
var action = actionExtract(entityID);
var geometry = entityID && context.graph().hasEntity(entityID) && context.graph().geometry(entityID);
var extent = geometry === 'area' && context.entity(entityID).extent(context.graph());
var operation = function () {
context.perform(action); // do the extract
context.validator().validate();
var extractedNodeID = action.getExtractedNodeID();
var mouse = context.map().mouseCoordinates();
if (mouse.some(isNaN)) {
enterMoveMode();
} else {
// move detached node to the mouse location (transitioned)
context.perform(actionMoveNode(extractedNodeID, mouse));
// after transition completes, put at final mouse location and enter move mode.
window.setTimeout(function() {
mouse = context.map().mouseCoordinates();
context.replace(actionMoveNode(extractedNodeID, mouse));
enterMoveMode();
}, 150);
}
function enterMoveMode() {
var baseGraph = context.graph();
context.enter(modeMove(context, [extractedNodeID], baseGraph));
}
context.perform(action, operation.annotation()); // do the extract
context.enter(modeSelect(context, [action.getExtractedNodeID()]));
};
+2 -2
View File
@@ -202,11 +202,11 @@ export function validationMismatchedGeometry() {
var extractOnClick = null;
if (!context.hasHiddenConnections(entityId) &&
!actionExtract(entityId, context.projection).disabled(context.graph())) {
!actionExtract(entityId).disabled(context.graph())) {
extractOnClick = function(context) {
var entityId = this.issue.entityIds[0];
var action = actionExtract(entityId, context.projection);
var action = actionExtract(entityId);
context.perform(
action,
t('operations.extract.annotation.single')