Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanded undo messages for node-dragging scenarios #5468

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,18 @@ en:
annotation: Removed a member from a relation.
connect:
annotation:
point: Connected a way to a point.
vertex: Connected a way to another.
line: Connected a way to a line.
area: Connected a way to an area.
from_vertex:
to_point: Connected a way to a point.
to_vertex: Connected a way to another.
to_line: Connected a way to a line.
to_area: Connected a way to an area.
to_adjacent_vertex: Merged adjacent points in a way.
to_sibling_vertex: Connected a way to itself.
from_point:
to_point: Merged a point with another.
to_vertex: Merged a point with a point in a way.
to_line: Moved a point to a line.
to_area: Moved a point to an area.
relation: These features can't be connected because they have conflicting relation roles.
restriction: "These features can't be connected because it would damage a \"{relation}\" relation."
disconnect:
Expand Down
18 changes: 14 additions & 4 deletions dist/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,20 @@
},
"connect": {
"annotation": {
"point": "Connected a way to a point.",
"vertex": "Connected a way to another.",
"line": "Connected a way to a line.",
"area": "Connected a way to an area."
"from_vertex": {
"to_point": "Connected a way to a point.",
"to_vertex": "Connected a way to another.",
"to_line": "Connected a way to a line.",
"to_area": "Connected a way to an area.",
"to_adjacent_vertex": "Merged adjacent points in a way.",
"to_sibling_vertex": "Connected a way to itself."
},
"from_point": {
"to_point": "Merged a point with another.",
"to_vertex": "Merged a point with a point in a way.",
"to_line": "Moved a point to a line.",
"to_area": "Moved a point to an area."
}
},
"relation": "These features can't be connected because they have conflicting relation roles.",
"restriction": "These features can't be connected because it would damage a \"{relation}\" relation."
Expand Down
24 changes: 20 additions & 4 deletions modules/modes/drag_node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _find from 'lodash-es/find';
import _intersection from 'lodash-es/intersection';

import {
event as d3_event,
Expand Down Expand Up @@ -75,8 +76,23 @@ export function modeDragNode(context) {
}


function connectAnnotation(entity) {
return t('operations.connect.annotation.' + entity.geometry(context.graph()));
function connectAnnotation(nodeEntity, targetEntity) {
var nodeGeometry = nodeEntity.geometry(context.graph());
var targetGeometry = targetEntity.geometry(context.graph());
if (nodeGeometry === 'vertex' && targetGeometry === 'vertex') {
var nodeParentWayIDs = context.graph().parentWays(nodeEntity);
var targetParentWayIDs = context.graph().parentWays(targetEntity);
var sharedParentWays = _intersection(nodeParentWayIDs, targetParentWayIDs);
// if both vertices are part of the same way
if (sharedParentWays.length !== 0) {
// if the nodes are next to each other, they are merged
if (sharedParentWays[0].areAdjacent(nodeEntity.id, targetEntity.id)) {
return t('operations.connect.annotation.from_vertex.to_adjacent_vertex');
}
return t('operations.connect.annotation.from_vertex.to_sibling_vertex');
}
}
return t('operations.connect.annotation.from_' + nodeGeometry + '.to_' + targetGeometry);
}


Expand Down Expand Up @@ -359,13 +375,13 @@ export function modeDragNode(context) {
loc: choice.loc,
edge: [target.nodes[choice.index - 1], target.nodes[choice.index]]
}, entity),
connectAnnotation(target)
connectAnnotation(entity, target)
);

} else if (target && target.type === 'node') {
context.replace(
actionConnect([target.id, entity.id]),
connectAnnotation(target)
connectAnnotation(entity, target)
);

} else if (_wasMidpoint) {
Expand Down