diff --git a/data/presets.yaml b/data/presets.yaml index d6b71e60d..9a8c58b76 100644 --- a/data/presets.yaml +++ b/data/presets.yaml @@ -1298,6 +1298,14 @@ en: tunnel: Tunnel # structure field placeholder placeholder: Unknown + structure_waterway: + # tunnel=* + label: Structure + options: + # tunnel=yes + tunnel: Tunnel + # structure_waterway field placeholder + placeholder: Unknown studio: # studio=* label: Type @@ -1424,9 +1432,6 @@ en: label: Type # tunnel field placeholder placeholder: Default - tunnel_waterway: - # tunnel=* - label: Tunnel vending: # vending=* label: Type of Goods diff --git a/data/presets/fields.json b/data/presets/fields.json index 2c3bcc800..a8d72e5b1 100644 --- a/data/presets/fields.json +++ b/data/presets/fields.json @@ -1750,6 +1750,19 @@ } } }, + "structure_waterway": { + "type": "structureRadio", + "keys": [ + "tunnel" + ], + "label": "Structure", + "placeholder": "Unknown", + "strings": { + "options": { + "tunnel": "Tunnel" + } + } + }, "structure": { "type": "structureRadio", "keys": [ @@ -1929,11 +1942,6 @@ "type": "semiCombo", "label": "Trees" }, - "tunnel_waterway": { - "key": "tunnel", - "type": "combo", - "label": "Tunnel" - }, "tunnel": { "key": "tunnel", "type": "typeCombo", diff --git a/data/presets/fields/structure_waterway.json b/data/presets/fields/structure_waterway.json new file mode 100644 index 000000000..d2ee7dd11 --- /dev/null +++ b/data/presets/fields/structure_waterway.json @@ -0,0 +1,13 @@ +{ + "type": "structureRadio", + "keys": [ + "tunnel" + ], + "label": "Structure", + "placeholder": "Unknown", + "strings": { + "options": { + "tunnel": "Tunnel" + } + } +} diff --git a/data/presets/fields/tunnel_waterway.json b/data/presets/fields/tunnel_waterway.json deleted file mode 100644 index 2c4f7751f..000000000 --- a/data/presets/fields/tunnel_waterway.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "key": "tunnel", - "type": "combo", - "label": "Tunnel" -} diff --git a/data/presets/presets.json b/data/presets/presets.json index 6867c1aef..a260c1694 100644 --- a/data/presets/presets.json +++ b/data/presets/presets.json @@ -15987,7 +15987,7 @@ "waterway/ditch": { "icon": "waterway-ditch", "fields": [ - "tunnel_waterway", + "structure_waterway", "intermittent" ], "geometry": [ @@ -16024,7 +16024,7 @@ "waterway/drain": { "icon": "waterway-stream", "fields": [ - "tunnel_waterway", + "structure_waterway", "intermittent" ], "geometry": [ @@ -16063,7 +16063,7 @@ "icon": "waterway-river", "fields": [ "name", - "tunnel_waterway", + "structure_waterway", "width", "intermittent" ], @@ -16135,7 +16135,7 @@ "icon": "waterway-stream", "fields": [ "name", - "tunnel_waterway", + "structure_waterway", "width", "intermittent" ], @@ -16178,7 +16178,7 @@ "icon": "waterway-stream", "fields": [ "name", - "tunnel_waterway", + "structure_waterway", "width", "intermittent" ], diff --git a/data/presets/presets/waterway/ditch.json b/data/presets/presets/waterway/ditch.json index e5ff49863..496a4ec72 100644 --- a/data/presets/presets/waterway/ditch.json +++ b/data/presets/presets/waterway/ditch.json @@ -1,7 +1,7 @@ { "icon": "waterway-ditch", "fields": [ - "tunnel_waterway", + "structure_waterway", "intermittent" ], "geometry": [ diff --git a/data/presets/presets/waterway/drain.json b/data/presets/presets/waterway/drain.json index 614284713..e1436c8b0 100644 --- a/data/presets/presets/waterway/drain.json +++ b/data/presets/presets/waterway/drain.json @@ -1,7 +1,7 @@ { "icon": "waterway-stream", "fields": [ - "tunnel_waterway", + "structure_waterway", "intermittent" ], "geometry": [ diff --git a/data/presets/presets/waterway/river.json b/data/presets/presets/waterway/river.json index a4448bf67..50c2c91ee 100644 --- a/data/presets/presets/waterway/river.json +++ b/data/presets/presets/waterway/river.json @@ -2,7 +2,7 @@ "icon": "waterway-river", "fields": [ "name", - "tunnel_waterway", + "structure_waterway", "width", "intermittent" ], diff --git a/data/presets/presets/waterway/stream.json b/data/presets/presets/waterway/stream.json index 3b26a9436..966a808ec 100644 --- a/data/presets/presets/waterway/stream.json +++ b/data/presets/presets/waterway/stream.json @@ -2,7 +2,7 @@ "icon": "waterway-stream", "fields": [ "name", - "tunnel_waterway", + "structure_waterway", "width", "intermittent" ], diff --git a/data/presets/presets/waterway/stream_intermittent.json b/data/presets/presets/waterway/stream_intermittent.json index e6ff48837..d74f62532 100644 --- a/data/presets/presets/waterway/stream_intermittent.json +++ b/data/presets/presets/waterway/stream_intermittent.json @@ -2,7 +2,7 @@ "icon": "waterway-stream", "fields": [ "name", - "tunnel_waterway", + "structure_waterway", "width", "intermittent" ], diff --git a/dist/locales/en.json b/dist/locales/en.json index be43857fb..6c3ecad14 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -2166,6 +2166,13 @@ "minor": "Minor Road" } }, + "structure_waterway": { + "label": "Structure", + "placeholder": "Unknown", + "options": { + "tunnel": "Tunnel" + } + }, "structure": { "label": "Structure", "placeholder": "Unknown", @@ -2278,9 +2285,6 @@ "trees": { "label": "Trees" }, - "tunnel_waterway": { - "label": "Tunnel" - }, "tunnel": { "label": "Type", "placeholder": "Default" diff --git a/modules/ui/fields/radio.js b/modules/ui/fields/radio.js index debeca172..aeb552b76 100644 --- a/modules/ui/fields/radio.js +++ b/modules/ui/fields/radio.js @@ -1,11 +1,9 @@ import _clone from 'lodash-es/clone'; import _pull from 'lodash-es/pull'; +import _union from 'lodash-es/union'; import { dispatch as d3_dispatch } from 'd3-dispatch'; -import { - select as d3_select, - selectAll as d3_selectAll -} from 'd3-selection'; +import { select as d3_select } from 'd3-selection'; import { t } from '../../util/locale'; import { uiField } from '../field'; @@ -156,7 +154,7 @@ export function uiFieldRadio(field, context) { .on('change', changeLayer); } layerField.tags(tags); - field.keys.push('layer'); + field.keys = _union(field.keys, ['layer']); } else { layerField = null; _pull(field.keys, 'layer'); @@ -200,7 +198,16 @@ export function uiFieldRadio(field, context) { if (!key) return; var val = t[key]; - if (val !== 'no') oldType[key] = val; + if (val !== 'no') { + oldType[key] = val; + } + + if (field.type === 'structureRadio') { + if (val === 'no' || (key !== 'bridge' && key !== 'tunnel')) { + t.layer = undefined; + } + } + dispatch.call('change', this, t, onInput); } @@ -269,6 +276,12 @@ export function uiFieldRadio(field, context) { } if (field.type === 'structureRadio') { + // For waterways without a tunnel tag, set 'culvert' as + // the oldType to default to if the user picks 'tunnel' + if (!!tags.waterway && !oldType.tunnel) { + oldType.tunnel = 'culvert'; + } + wrap.call(structureExtras, tags); } };