Checkmark fields now support custom string options

oneway fields now show "Assumed to be No" or "Assumed to be Yes" instead of "Unknown" #2220
This commit is contained in:
Bryan Housel
2014-05-22 13:48:04 -04:00
parent d973580203
commit e3e2ea602a
8 changed files with 75 additions and 19 deletions
+8
View File
@@ -240,8 +240,16 @@ en:
label: Type
oneway:
label: One Way
options:
undefined: Assumed to be No
yes: Yes
no: No
oneway_yes:
label: One Way
options:
undefined: Assumed to be Yes
yes: Yes
no: No
opening_hours:
label: Hours
operator:
+16 -2
View File
@@ -570,13 +570,27 @@
"oneway": {
"key": "oneway",
"type": "check",
"label": "One Way"
"label": "One Way",
"strings": {
"options": {
"undefined": "Assumed to be No",
"yes": "Yes",
"no": "No"
}
}
},
"oneway_yes": {
"key": "oneway",
"type": "check",
"default": "yes",
"label": "One Way"
"label": "One Way",
"strings": {
"options": {
"undefined": "Assumed to be Yes",
"yes": "Yes",
"no": "No"
}
}
},
"opening_hours": {
"key": "opening_hours",
+8 -1
View File
@@ -1,5 +1,12 @@
{
"key": "oneway",
"type": "check",
"label": "One Way"
"label": "One Way",
"strings": {
"options": {
"undefined": "Assumed to be No",
"yes": "Yes",
"no": "No"
}
}
}
+8 -1
View File
@@ -2,5 +2,12 @@
"key": "oneway",
"type": "check",
"default": "yes",
"label": "One Way"
"label": "One Way",
"strings": {
"options": {
"undefined": "Assumed to be Yes",
"yes": "Yes",
"no": "No"
}
}
}
+1 -1
View File
@@ -3822,7 +3822,7 @@
"highway/motorway": {
"icon": "highway-motorway",
"fields": [
"oneway",
"oneway_yes",
"maxspeed",
"structure",
"access",
+2 -2
View File
@@ -1,7 +1,7 @@
{
"icon": "highway-motorway",
"fields": [
"oneway",
"oneway_yes",
"maxspeed",
"structure",
"access",
@@ -17,4 +17,4 @@
},
"terms": [],
"name": "Motorway"
}
}
+12 -2
View File
@@ -743,10 +743,20 @@
"label": "Type"
},
"oneway": {
"label": "One Way"
"label": "One Way",
"options": {
"undefined": "Assumed to be No",
"yes": "Yes",
"no": "No"
}
},
"oneway_yes": {
"label": "One Way"
"label": "One Way",
"options": {
"undefined": "Assumed to be Yes",
"yes": "Yes",
"no": "No"
}
},
"opening_hours": {
"label": "Hours"
+20 -10
View File
@@ -1,13 +1,24 @@
iD.ui.preset.check =
iD.ui.preset.defaultcheck = function(field) {
var event = d3.dispatch('change'),
values = field.type === 'check' ?
[undefined, 'yes', 'no'] :
[undefined, 'yes'],
value,
box,
text,
label;
options = field.strings && field.strings.options,
values = [],
texts = [],
value, box, text, label;
if (options) {
for (var k in options) {
values.push(k === 'undefined' ? undefined : k);
texts.push(field.t('check.' + k, { 'default': options[k] }));
}
} else {
values = [undefined, 'yes'];
texts = [t('inspector.unknown'), t('inspector.check.yes')];
if (field.type === 'check') {
values.push('no');
texts.push(t('inspector.check.no'));
}
}
var check = function(selection) {
selection.classed('checkselect', 'true');
@@ -24,7 +35,7 @@ iD.ui.preset.defaultcheck = function(field) {
.attr('id', 'preset-input-' + field.id);
enter.append('span')
.text(t('inspector.unknown'))
.text(texts[0])
.attr('class', 'value');
box = label.select('input')
@@ -42,8 +53,7 @@ iD.ui.preset.defaultcheck = function(field) {
value = tags[field.key];
box.property('indeterminate', field.type === 'check' && !value);
box.property('checked', value === 'yes');
text.text(value ? t('inspector.check.' + value, {default: value}) :
field.type === 'check' ? t('inspector.unknown') : t('inspector.check.no'));
text.text(texts[values.indexOf(value)]);
label.classed('set', !!value);
};