Create a new manyCombo field type for the public transport vehicles field instead of using multiCombo in a new way (re: #6142)

This commit is contained in:
Quincy Morgan
2020-09-24 09:21:59 -04:00
parent 9effdf9724
commit f163722c9a
9 changed files with 14 additions and 9 deletions
+3 -1
View File
@@ -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<br/>
(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<br/>
* `multiCombo` - Dropdown field for adding `yes` values to multiple keys with the same prefix (a common multikey)<br/>
(e.g. `recycling:*` -> `recycling:glass=yes`, `recycling:paper=yes`, etc.)
* `manyCombo` - Dropdown field for adding `yes` values to many different keys<br/>
(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<br/>
(e.g. `sport=*` -> `soccer;lacrosse;athletics;field_hockey`)
+1 -1
View File
@@ -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"},
+1 -1
View File
@@ -9,7 +9,7 @@
"monorail",
"ferry"
],
"type": "multiCombo",
"type": "manyCombo",
"label": "Vehicles",
"strings": {
"options": {
+1
View File
@@ -58,6 +58,7 @@
"lanes",
"identifier",
"localized",
"manyCombo",
"maxspeed",
"multiCombo",
"networkCombo",
+1 -1
View File
@@ -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;
+2 -1
View File
@@ -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;
+2
View File
@@ -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,
+1 -1
View File
@@ -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();
}
})
+2 -3
View File
@@ -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 };