mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-19 23:14:47 +02:00
Allow disconnecting an entire way from other ways at once (close #4245)
This commit is contained in:
@@ -82,9 +82,6 @@ export function actionDisconnect(nodeId, newNodeId) {
|
||||
var sharedRelation;
|
||||
|
||||
parentWays.forEach(function(way) {
|
||||
if (wayIds && wayIds.indexOf(way.id) === -1)
|
||||
return;
|
||||
|
||||
var relations = graph.parentRelations(way);
|
||||
relations.forEach(function(relation) {
|
||||
if (relation.id in seenRelationIds) {
|
||||
|
||||
@@ -7,6 +7,7 @@ export function operationDisconnect(selectedIDs, context) {
|
||||
var vertices = [],
|
||||
ways = [],
|
||||
others = [];
|
||||
var extent;
|
||||
|
||||
selectedIDs.forEach(function(id) {
|
||||
if (context.geometry(id) === 'vertex') {
|
||||
@@ -20,17 +21,30 @@ export function operationDisconnect(selectedIDs, context) {
|
||||
|
||||
var actions = [];
|
||||
|
||||
vertices.forEach(function(vertexID) {
|
||||
var action = actionDisconnect(vertexID);
|
||||
var disconnectingWay = vertices.length === 0 && ways.length === 1 && ways[0];
|
||||
|
||||
if (ways.length > 0) {
|
||||
var waysIDsForVertex = ways.filter(function(wayID) {
|
||||
return context.graph().entity(wayID).nodes.includes(vertexID);
|
||||
});
|
||||
action.limitWays(waysIDsForVertex);
|
||||
}
|
||||
actions.push(action);
|
||||
});
|
||||
if (disconnectingWay) {
|
||||
extent = context.entity(disconnectingWay).extent(context.graph());
|
||||
|
||||
context.entity(disconnectingWay).nodes.forEach(function(vertexID) {
|
||||
var action = actionDisconnect(vertexID).limitWays(ways);
|
||||
if (action.disabled(context.graph()) !== 'not_connected') {
|
||||
actions.push(action);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
vertices.forEach(function(vertexID) {
|
||||
var action = actionDisconnect(vertexID);
|
||||
|
||||
if (ways.length > 0) {
|
||||
var waysIDsForVertex = ways.filter(function(wayID) {
|
||||
return context.graph().entity(wayID).nodes.includes(vertexID);
|
||||
});
|
||||
action.limitWays(waysIDsForVertex);
|
||||
}
|
||||
actions.push(action);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var operation = function() {
|
||||
@@ -44,18 +58,26 @@ export function operationDisconnect(selectedIDs, context) {
|
||||
|
||||
|
||||
operation.available = function() {
|
||||
return vertices.length > 0 &&
|
||||
others.length === 0 &&
|
||||
(ways.length === 0 || ways.every(function(way) {
|
||||
return vertices.some(function(vertex) {
|
||||
return context.graph().entity(way).nodes.includes(vertex);
|
||||
});
|
||||
}));
|
||||
|
||||
if (actions.length === 0) return false;
|
||||
|
||||
if (others.length !== 0) return false;
|
||||
|
||||
if (vertices.length !== 0 && ways.length !== 0 && !ways.every(function(way) {
|
||||
return vertices.some(function(vertex) {
|
||||
return context.graph().entity(way).nodes.includes(vertex);
|
||||
});
|
||||
})) return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
operation.disabled = function() {
|
||||
var reason;
|
||||
if (extent && extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
return 'too_large.single';
|
||||
}
|
||||
if (selectedIDs.some(context.hasHiddenConnections)) {
|
||||
reason = 'connected_to_hidden';
|
||||
}
|
||||
@@ -70,9 +92,13 @@ export function operationDisconnect(selectedIDs, context) {
|
||||
|
||||
operation.tooltip = function() {
|
||||
var disable = operation.disabled();
|
||||
return disable ?
|
||||
t('operations.disconnect.' + disable) :
|
||||
t('operations.disconnect.description');
|
||||
if (disable) {
|
||||
return t('operations.disconnect.' + disable);
|
||||
}
|
||||
if (disconnectingWay) {
|
||||
return t('operations.disconnect.' + context.geometry(disconnectingWay) + '.description');
|
||||
}
|
||||
return t('operations.disconnect.description');
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user