From 1daab1576621b17f0342407e7be54338a936eac1 Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Tue, 29 Sep 2020 14:15:40 -0400 Subject: [PATCH] Add more exacting descriptions for splitting different amounts of different types of features at different amounts of points (re: #7990) --- data/core.yaml | 29 +++++++++++++++++++++------ dist/locales/en.json | 39 +++++++++++++++++++++++++++++++------ modules/operations/split.js | 23 +++++++++++++--------- 3 files changed, 70 insertions(+), 21 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index 8ce4f2c63..3b1696b0d 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -442,18 +442,35 @@ en: split: title: Split description: - line: Split this line into two at this node. - area: Split the boundary of this area into two. - multiple: Split the lines/area boundaries at this node into two. + line: + single: + single_node: Divide this line into two at this point. + multiple_node: Divide this line at these points. + multiple: + single_node: Divide these lines at this point. + multiple_node: Divide these lines at these points. + area: + single: + single_node: Divide the edge of this area into two at this point. + multiple_node: Divide the edge of this area at these points. + multiple: + single_node: Divide the edges of these areas at this point. + multiple_node: Divide the edges of these areas at these points. + feature: + multiple: + multiple_node: Divide these features at these points. key: X annotation: - line: Split a line. - area: Split an area boundary. + line: + one: "Split a line." + other: "Split {n} lines." + area: + one: "Split the edge of an area." + other: "Split {n} areas." feature: one: "Split a feature." other: "Split {n} features." not_eligible: Lines can't be split at their beginning or end. - multiple_ways: There are too many lines here to split. connected_to_hidden: This can't be split because it is connected to a hidden feature. restriction: annotation: diff --git a/dist/locales/en.json b/dist/locales/en.json index 75e3a1679..fbf805573 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -590,21 +590,48 @@ "split": { "title": "Split", "description": { - "line": "Split this line into two at this node.", - "area": "Split the boundary of this area into two.", - "multiple": "Split the lines/area boundaries at this node into two." + "line": { + "single": { + "single_node": "Divide this line into two at this point.", + "multiple_node": "Divide this line at these points." + }, + "multiple": { + "single_node": "Divide these lines at this point.", + "multiple_node": "Divide these lines at these points." + } + }, + "area": { + "single": { + "single_node": "Divide the edge of this area into two at this point.", + "multiple_node": "Divide the edge of this area at these points." + }, + "multiple": { + "single_node": "Divide the edges of these areas at this point.", + "multiple_node": "Divide the edges of these areas at these points." + } + }, + "feature": { + "multiple": { + "multiple_node": "Divide these features at these points." + } + } }, "key": "X", "annotation": { - "line": "Split a line.", - "area": "Split an area boundary.", + "line": { + "one": "Split a line.", + "other": "Split {n} lines." + }, + "area": { + "one": "Split the edge of an area.", + "other": "Split {n} areas." + }, "feature": { "one": "Split a feature.", "other": "Split {n} features." } }, "not_eligible": "Lines can't be split at their beginning or end.", - "multiple_ways": "There are too many lines here to split.", "connected_to_hidden": "This can't be split because it is connected to a hidden feature." }, "restriction": { diff --git a/modules/operations/split.js b/modules/operations/split.js index dd691568f..d43344309 100644 --- a/modules/operations/split.js +++ b/modules/operations/split.js @@ -16,10 +16,21 @@ export function operationSplit(context, selectedIDs) { _vertexIds.length + _selectedWayIds.length === selectedIDs.length; var _action = actionSplit(_vertexIds); var _ways = []; + var _geometry = 'feature'; + var _waysAmount = 'single'; + var _nodesAmount = _vertexIds.length === 1 ? 'single' : 'multiple'; if (_isAvailable) { if (_selectedWayIds.length) _action.limitWays(_selectedWayIds); _ways = _action.ways(context.graph()); + var geometries = {}; + _ways.forEach(function(way) { + geometries[way.geometry(context.graph())] = true; + }); + if (Object.keys(geometries).length === 1) { + _geometry = Object.keys(geometries)[0]; + } + _waysAmount = _ways.length === 1 ? 'single' : 'multiple'; } @@ -47,19 +58,13 @@ export function operationSplit(context, selectedIDs) { operation.tooltip = function() { var disable = operation.disabled(); - if (disable) { - return t('operations.split.' + disable); - } else if (_ways.length === 1) { - return t('operations.split.description.' + context.graph().geometry(_ways[0].id)); - } - return t('operations.split.description.multiple'); + if (disable) return t('operations.split.' + disable); + return t('operations.split.description.' + _geometry + '.' + _waysAmount + '.' + _nodesAmount + '_node'); }; operation.annotation = function() { - return _ways.length === 1 ? - t('operations.split.annotation.' + context.graph().geometry(_ways[0].id)) : - t('operations.split.annotation.feature', { n: _ways.length }); + return t('operations.split.annotation.' + _geometry, { n: _ways.length }); };