mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Merge pull request #8577 from openstreetmap/issue-8298
Select [selectChild] - differentiate parent/child selection
This commit is contained in:
@@ -2301,6 +2301,9 @@ en:
|
||||
last: "Jump to last node"
|
||||
parent: "Select parent way"
|
||||
change_parent: "Switch parent way"
|
||||
way_selected:
|
||||
title: "With way selected"
|
||||
child: "Select child nodes"
|
||||
editing:
|
||||
title: "Editing"
|
||||
drawing:
|
||||
|
||||
@@ -85,11 +85,7 @@
|
||||
{
|
||||
"shortcuts": ["map_data.highlight_edits.key"],
|
||||
"text": "shortcuts.browsing.display_options.highlight_edits"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rows": [
|
||||
},
|
||||
{
|
||||
"section": "help",
|
||||
"text": "shortcuts.browsing.help.title"
|
||||
@@ -101,7 +97,11 @@
|
||||
{
|
||||
"shortcuts": ["shortcuts.toggle.key", "?"],
|
||||
"text": "shortcuts.browsing.help.keyboard"
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rows": [
|
||||
{
|
||||
"section": "selecting",
|
||||
"text": "shortcuts.browsing.selecting.title"
|
||||
@@ -159,12 +159,22 @@
|
||||
"text": "shortcuts.browsing.vertex_selected.last"
|
||||
},
|
||||
{
|
||||
"shortcuts": ["|"],
|
||||
"modifiers": ["⌘"],
|
||||
"shortcuts": ["↑"],
|
||||
"text": "shortcuts.browsing.vertex_selected.parent"
|
||||
},
|
||||
{
|
||||
"shortcuts": ["\\", "shortcuts.key.pause"],
|
||||
"text": "shortcuts.browsing.vertex_selected.change_parent"
|
||||
},
|
||||
{
|
||||
"section": "way_selected",
|
||||
"text": "shortcuts.browsing.way_selected.title"
|
||||
},
|
||||
{
|
||||
"modifiers": ["⌘"],
|
||||
"shortcuts": ["↓"],
|
||||
"text": "shortcuts.browsing.way_selected.child"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
2
dist/locales/en.min.json
vendored
2
dist/locales/en.min.json
vendored
File diff suppressed because one or more lines are too long
@@ -113,6 +113,31 @@ export function modeSelect(context, selectedIDs) {
|
||||
return parents;
|
||||
}
|
||||
|
||||
// find the child nodes for selected ways
|
||||
function childNodeIdsOfSelection(onlyCommon) {
|
||||
var graph = context.graph();
|
||||
var childs = [];
|
||||
|
||||
for (var i = 0; i < selectedIDs.length; i++) {
|
||||
var entity = context.hasEntity(selectedIDs[i]);
|
||||
|
||||
if (!entity || !['area', 'line'].includes(entity.geometry(graph))){
|
||||
return []; // selection includes non-area/non-line
|
||||
}
|
||||
var currChilds = graph.childNodes(entity).map(function(node) { return node.id; });
|
||||
if (!childs.length) {
|
||||
childs = currChilds;
|
||||
continue;
|
||||
}
|
||||
|
||||
childs = (onlyCommon ? utilArrayIntersection : utilArrayUnion)(childs, currChilds);
|
||||
if (!childs.length) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
return childs;
|
||||
}
|
||||
|
||||
function checkFocusedParent() {
|
||||
if (_focusedParentWayId) {
|
||||
@@ -244,7 +269,8 @@ export function modeSelect(context, selectedIDs) {
|
||||
.on(utilKeybinding.minusKeys.map((key) => uiCmd('⇧' + key)), scaleSelection(1/1.05))
|
||||
.on(utilKeybinding.minusKeys.map((key) => uiCmd('⇧⌥' + key)), scaleSelection(1/Math.pow(1.05, 5)))
|
||||
.on(['\\', 'pause'], focusNextParent)
|
||||
.on('|', selectParent)
|
||||
.on(uiCmd('⌘↑'), selectParent)
|
||||
.on(uiCmd('⌘↓'), selectChild)
|
||||
.on('⎋', esc, true);
|
||||
|
||||
d3_select(document)
|
||||
@@ -576,24 +602,28 @@ export function modeSelect(context, selectedIDs) {
|
||||
|
||||
var currentSelectedIds = mode.selectedIDs();
|
||||
var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
|
||||
if (!parentIds.length) return;
|
||||
|
||||
if (!parentIds.length) {
|
||||
var reselectIds = _focusedVertexIds && _focusedVertexIds.filter(id => context.hasEntity(id));
|
||||
context.enter(
|
||||
mode.selectedIDs(parentIds)
|
||||
);
|
||||
// set this after re-entering the selection since we normally want it cleared on exit
|
||||
_focusedVertexIds = currentSelectedIds;
|
||||
}
|
||||
|
||||
if (reselectIds && reselectIds.length) {
|
||||
if (currentSelectedIds.length === 1) _focusedParentWayId = currentSelectedIds[0];
|
||||
context.enter(
|
||||
mode.selectedIDs(_focusedVertexIds)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
function selectChild(d3_event) {
|
||||
d3_event.preventDefault();
|
||||
|
||||
context.enter(
|
||||
mode.selectedIDs(parentIds)
|
||||
);
|
||||
// set this after re-entering the selection since we normally want it cleared on exit
|
||||
_focusedVertexIds = currentSelectedIds;
|
||||
}
|
||||
var currentSelectedIds = mode.selectedIDs();
|
||||
|
||||
var childIds = _focusedVertexIds ? _focusedVertexIds.filter(id => context.hasEntity(id)) : childNodeIdsOfSelection(true);
|
||||
if (!childIds || !childIds.length) return;
|
||||
|
||||
if (currentSelectedIds.length === 1) _focusedParentWayId = currentSelectedIds[0];
|
||||
|
||||
context.enter(
|
||||
mode.selectedIDs(childIds)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user