Replace tunnel_waterway combo with structure_water radio

(closes #4384)

- adds the `layer` field so it works like the structure field on highways
- also defaults the tunnel type to `culvert` for waterways
- also fixed so that `layer` gets removed if user changes types or clicks delete
This commit is contained in:
Bryan Housel
2017-10-02 11:24:59 -04:00
parent 7376787c44
commit 2b47ac4b3e
12 changed files with 70 additions and 32 deletions
+8 -3
View File
@@ -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
+13 -5
View File
@@ -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",
@@ -0,0 +1,13 @@
{
"type": "structureRadio",
"keys": [
"tunnel"
],
"label": "Structure",
"placeholder": "Unknown",
"strings": {
"options": {
"tunnel": "Tunnel"
}
}
}
-5
View File
@@ -1,5 +0,0 @@
{
"key": "tunnel",
"type": "combo",
"label": "Tunnel"
}
+5 -5
View File
@@ -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"
],
+1 -1
View File
@@ -1,7 +1,7 @@
{
"icon": "waterway-ditch",
"fields": [
"tunnel_waterway",
"structure_waterway",
"intermittent"
],
"geometry": [
+1 -1
View File
@@ -1,7 +1,7 @@
{
"icon": "waterway-stream",
"fields": [
"tunnel_waterway",
"structure_waterway",
"intermittent"
],
"geometry": [
+1 -1
View File
@@ -2,7 +2,7 @@
"icon": "waterway-river",
"fields": [
"name",
"tunnel_waterway",
"structure_waterway",
"width",
"intermittent"
],
+1 -1
View File
@@ -2,7 +2,7 @@
"icon": "waterway-stream",
"fields": [
"name",
"tunnel_waterway",
"structure_waterway",
"width",
"intermittent"
],
@@ -2,7 +2,7 @@
"icon": "waterway-stream",
"fields": [
"name",
"tunnel_waterway",
"structure_waterway",
"width",
"intermittent"
],
+7 -3
View File
@@ -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"
+19 -6
View File
@@ -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);
}
};