From f163722c9a1d40cb4daccd9e7adcffd9b55b1323 Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Thu, 24 Sep 2020 09:21:59 -0400 Subject: [PATCH] Create a new `manyCombo` field type for the public transport vehicles field instead of using `multiCombo` in a new way (re: #6142) --- data/presets/README.md | 4 +++- data/presets/fields.json | 2 +- data/presets/fields/vehicles.json | 2 +- data/presets/schema/field.json | 1 + modules/presets/preset.js | 2 +- modules/ui/fields/combo.js | 3 ++- modules/ui/fields/index.js | 2 ++ modules/ui/form_fields.js | 2 +- scripts/build_data.js | 5 ++--- 9 files changed, 14 insertions(+), 9 deletions(-) diff --git a/data/presets/README.md b/data/presets/README.md index 8ca30aae6..85784c0e7 100644 --- a/data/presets/README.md +++ b/data/presets/README.md @@ -270,8 +270,10 @@ A string specifying the UI and behavior of the field. Must be one of the followi * `combo` - Dropdown field for picking one option out of many (e.g. `surface=*`) * `typeCombo` - Dropdown field picking a specific type from a generic category key
(e.g. `waterway=*`. If unset, tag will be `waterway=yes`, but dropdown contains options like `stream`, `ditch`, `river`) -* `multiCombo` - Dropdown field for adding `yes` values to a common multikey
+* `multiCombo` - Dropdown field for adding `yes` values to multiple keys with the same prefix (a common multikey)
(e.g. `recycling:*` -> `recycling:glass=yes`, `recycling:paper=yes`, etc.) +* `manyCombo` - Dropdown field for adding `yes` values to many different keys
+(e.g. `bus`, `tram`, `train` -> `bus=yes`, `tram=yes`, etc.) * `networkCombo` - Dropdown field that helps users pick a route `network` tag (localized for editing location) * `semiCombo` - Dropdown field for adding multiple values to a semicolon-delimited list
(e.g. `sport=*` -> `soccer;lacrosse;athletics;field_hockey`) diff --git a/data/presets/fields.json b/data/presets/fields.json index 62f05183e..19ea5ce0a 100644 --- a/data/presets/fields.json +++ b/data/presets/fields.json @@ -486,7 +486,7 @@ "utility_semi": {"key": "utility", "type": "semiCombo", "label": "Utilities"}, "utility": {"key": "utility", "type": "typeCombo", "label": "Utility"}, "valve": {"key": "valve", "type": "combo", "label": "Type"}, - "vehicles": {"keys": ["bus", "trolleybus", "tram", "train", "subway", "light_rail", "monorail", "ferry"], "type": "multiCombo", "label": "Vehicles", "strings": {"options": {"bus": "Bus", "trolleybus": "Trolleybus", "tram": "Tram", "train": "Train", "subway": "Subway", "light_rail": "Light Rail", "monorail": "Monorail", "ferry": "Ferry"}}, "reference": {"key": "public_transport"}, "prerequisiteTag": {"keyNot": "aerialway"}}, + "vehicles": {"keys": ["bus", "trolleybus", "tram", "train", "subway", "light_rail", "monorail", "ferry"], "type": "manyCombo", "label": "Vehicles", "strings": {"options": {"bus": "Bus", "trolleybus": "Trolleybus", "tram": "Tram", "train": "Train", "subway": "Subway", "light_rail": "Light Rail", "monorail": "Monorail", "ferry": "Ferry"}}, "reference": {"key": "public_transport"}, "prerequisiteTag": {"keyNot": "aerialway"}}, "vending": {"key": "vending", "type": "semiCombo", "label": "Types of Goods"}, "vhf": {"key": "vhf", "type": "text", "label": "VHF Channel", "terms": ["call sign", "very high frequency"]}, "video_calls": {"key": "video", "type": "check", "label": "Video Calls"}, diff --git a/data/presets/fields/vehicles.json b/data/presets/fields/vehicles.json index 65c93d4f8..c487d0383 100644 --- a/data/presets/fields/vehicles.json +++ b/data/presets/fields/vehicles.json @@ -9,7 +9,7 @@ "monorail", "ferry" ], - "type": "multiCombo", + "type": "manyCombo", "label": "Vehicles", "strings": { "options": { diff --git a/data/presets/schema/field.json b/data/presets/schema/field.json index e027663b9..ddd7c762c 100644 --- a/data/presets/schema/field.json +++ b/data/presets/schema/field.json @@ -58,6 +58,7 @@ "lanes", "identifier", "localized", + "manyCombo", "maxspeed", "multiCombo", "networkCombo", diff --git a/modules/presets/preset.js b/modules/presets/preset.js index 5993f89c3..7ad508e0b 100644 --- a/modules/presets/preset.js +++ b/modules/presets/preset.js @@ -248,7 +248,7 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) { function shouldInherit(f) { if (f.key && _this.tags[f.key] !== undefined && // inherit anyway if multiple values are allowed or just a checkbox - f.type !== 'multiCombo' && f.type !== 'semiCombo' && f.type !== 'check' + f.type !== 'multiCombo' && f.type !== 'semiCombo' && f.type !== 'manyCombo' && f.type !== 'check' ) return false; return true; diff --git a/modules/ui/fields/combo.js b/modules/ui/fields/combo.js index 69b42965d..442ef9029 100644 --- a/modules/ui/fields/combo.js +++ b/modules/ui/fields/combo.js @@ -11,6 +11,7 @@ import { uiCombobox } from '../combobox'; import { utilArrayUniq, utilGetSetValue, utilNoAuto, utilRebind, utilTotalExtent, utilUnicodeCharsCount } from '../../util'; export { + uiFieldCombo as uiFieldManyCombo, uiFieldCombo as uiFieldMultiCombo, uiFieldCombo as uiFieldNetworkCombo, uiFieldCombo as uiFieldSemiCombo, @@ -20,7 +21,7 @@ export { export function uiFieldCombo(field, context) { var dispatch = d3_dispatch('change'); - var _isMulti = (field.type === 'multiCombo'); + var _isMulti = (field.type === 'multiCombo' || field.type === 'manyCombo'); var _isNetwork = (field.type === 'networkCombo'); var _isSemi = (field.type === 'semiCombo'); var _optstrings = field.strings && field.strings.options; diff --git a/modules/ui/fields/index.js b/modules/ui/fields/index.js index 34efd9a10..06e55f1e7 100644 --- a/modules/ui/fields/index.js +++ b/modules/ui/fields/index.js @@ -21,6 +21,7 @@ import { import { uiFieldCombo, + uiFieldManyCombo, uiFieldMultiCombo, uiFieldNetworkCombo, uiFieldSemiCombo, @@ -64,6 +65,7 @@ export var uiFields = { lanes: uiFieldLanes, localized: uiFieldLocalized, maxspeed: uiFieldMaxspeed, + manyCombo: uiFieldManyCombo, multiCombo: uiFieldMultiCombo, networkCombo: uiFieldNetworkCombo, number: uiFieldNumber, diff --git a/modules/ui/form_fields.js b/modules/ui/form_fields.js index 365a97457..ae6774d7c 100644 --- a/modules/ui/form_fields.js +++ b/modules/ui/form_fields.js @@ -113,7 +113,7 @@ export function uiFormFields(context) { var field = d.field; field.show(); selection.call(formFields); // rerender - if (field.type !== 'semiCombo' && field.type !== 'multiCombo') { + if (field.type !== 'semiCombo' && field.type !== 'multiCombo' && field.type !== 'manyCombo') { field.focus(); } }) diff --git a/scripts/build_data.js b/scripts/build_data.js index 24ef65988..3d47dd3dc 100644 --- a/scripts/build_data.js +++ b/scripts/build_data.js @@ -537,15 +537,14 @@ function generateTaginfo(presets, fields) { const field = fields[id]; const keys = field.keys || [ field.key ] || []; const isRadio = (field.type === 'radio' || field.type === 'structureRadio'); - const isMulticombo = field.type === 'multiCombo'; keys.forEach(key => { - if (field.strings && field.strings.options && !isRadio && (!isMulticombo || field.key)) { + if (field.strings && field.strings.options && !isRadio && field.type !== 'manyCombo') { let values = Object.keys(field.strings.options); values.forEach(value => { if (value === 'undefined' || value === '*' || value === '') return; let tag; - if (isMulticombo) { + if (field.type === 'multiCombo') { tag = { key: key + value }; } else { tag = { key: key, value: value };