mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-25 17:37:49 +02:00
Merge pull request #8264 from openstreetmap/1ec5-select-way-2225
Add shortcut to select parent way(s)
This commit is contained in:
@@ -2258,6 +2258,7 @@ en:
|
||||
next: "Jump to next node"
|
||||
first: "Jump to first node"
|
||||
last: "Jump to last node"
|
||||
parent: "Select parent way"
|
||||
change_parent: "Switch parent way"
|
||||
editing:
|
||||
title: "Editing"
|
||||
|
||||
@@ -158,6 +158,11 @@
|
||||
"shortcuts": ["}", "⇟"],
|
||||
"text": "shortcuts.browsing.vertex_selected.last"
|
||||
},
|
||||
{
|
||||
"modifiers": ["⌘"],
|
||||
"shortcuts": ["↑"],
|
||||
"text": "shortcuts.browsing.vertex_selected.parent"
|
||||
},
|
||||
{
|
||||
"shortcuts": ["\\", "shortcuts.key.pause"],
|
||||
"text": "shortcuts.browsing.vertex_selected.change_parent"
|
||||
|
||||
+22
-11
@@ -23,7 +23,7 @@ import { osmNode, osmWay } from '../osm';
|
||||
import * as Operations from '../operations/index';
|
||||
import { uiCmd } from '../ui/cmd';
|
||||
import {
|
||||
utilArrayIntersection, utilDeepMemberSelector, utilEntityOrDeepMemberSelector,
|
||||
utilArrayIntersection, utilArrayUnion, utilDeepMemberSelector, utilEntityOrDeepMemberSelector,
|
||||
utilEntitySelector, utilKeybinding, utilTotalExtent, utilGetAllNodes
|
||||
} from '../util';
|
||||
|
||||
@@ -85,10 +85,10 @@ export function modeSelect(context, selectedIDs) {
|
||||
}
|
||||
|
||||
|
||||
// find the common parent ways for nextVertex, previousVertex
|
||||
function commonParents() {
|
||||
// find the parent ways for nextVertex, previousVertex, and selectParent
|
||||
function multipleParents(onlyCommonParents) {
|
||||
var graph = context.graph();
|
||||
var commonParents = [];
|
||||
var parents = [];
|
||||
|
||||
for (var i = 0; i < selectedIDs.length; i++) {
|
||||
var entity = context.hasEntity(selectedIDs[i]);
|
||||
@@ -97,23 +97,23 @@ export function modeSelect(context, selectedIDs) {
|
||||
}
|
||||
|
||||
var currParents = graph.parentWays(entity).map(function(w) { return w.id; });
|
||||
if (!commonParents.length) {
|
||||
commonParents = currParents;
|
||||
if (!parents.length) {
|
||||
parents = currParents;
|
||||
continue;
|
||||
}
|
||||
|
||||
commonParents = utilArrayIntersection(commonParents, currParents);
|
||||
if (!commonParents.length) {
|
||||
parents = (onlyCommonParents ? utilArrayIntersection : utilArrayUnion)(parents, currParents);
|
||||
if (!parents.length) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
return commonParents;
|
||||
return parents;
|
||||
}
|
||||
|
||||
|
||||
function singularParent() {
|
||||
var parents = commonParents();
|
||||
var parents = multipleParents(true);
|
||||
if (!parents || parents.length === 0) {
|
||||
_relatedParent = null;
|
||||
return null;
|
||||
@@ -245,6 +245,7 @@ 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'], nextParent)
|
||||
.on(uiCmd('⌘↑'), selectParent)
|
||||
.on('⎋', esc, true);
|
||||
|
||||
d3_select(document)
|
||||
@@ -542,7 +543,7 @@ export function modeSelect(context, selectedIDs) {
|
||||
|
||||
function nextParent(d3_event) {
|
||||
d3_event.preventDefault();
|
||||
var parents = commonParents();
|
||||
var parents = multipleParents(true);
|
||||
if (!parents || parents.length < 2) return;
|
||||
|
||||
var index = parents.indexOf(_relatedParent);
|
||||
@@ -561,6 +562,16 @@ export function modeSelect(context, selectedIDs) {
|
||||
.classed('related', true);
|
||||
}
|
||||
}
|
||||
|
||||
function selectParent(d3_event) {
|
||||
d3_event.preventDefault();
|
||||
var parents = _relatedParent ? [_relatedParent] : multipleParents(false);
|
||||
if (!parents || parents.length === 0) return;
|
||||
|
||||
context.enter(
|
||||
modeSelect(context, parents)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user