mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-22 03:36:37 +02:00
Merge pull request #2235 from bhousel/bhousel-fields
Allow checkbox fields to support custom strings
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
dist/iD.js
|
||||
dist/iD.min.js
|
||||
dist/iD.css
|
||||
|
||||
@@ -244,8 +244,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:
|
||||
|
||||
@@ -575,13 +575,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",
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3822,7 +3822,7 @@
|
||||
"highway/motorway": {
|
||||
"icon": "highway-motorway",
|
||||
"fields": [
|
||||
"oneway",
|
||||
"oneway_yes",
|
||||
"maxspeed",
|
||||
"structure",
|
||||
"access",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"icon": "highway-motorway",
|
||||
"fields": [
|
||||
"oneway",
|
||||
"oneway_yes",
|
||||
"maxspeed",
|
||||
"structure",
|
||||
"access",
|
||||
@@ -17,4 +17,4 @@
|
||||
},
|
||||
"terms": [],
|
||||
"name": "Motorway"
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+12
-2
@@ -761,10 +761,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"
|
||||
|
||||
@@ -209,6 +209,7 @@
|
||||
<script src='js/id/core/way.js'></script>
|
||||
<script src='js/id/core/tree.js'></script>
|
||||
<script src='js/id/core/area_keys.js'></script>
|
||||
<script src='js/id/core/oneway_tags.js'></script>
|
||||
|
||||
<script src='js/id/presets.js'></script>
|
||||
<script src='js/id/presets/preset.js'></script>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
iD.oneWayTags = {
|
||||
'aerialway': {
|
||||
'chair_lift': true,
|
||||
'mixed_lift': true,
|
||||
't-bar': true,
|
||||
'j-bar': true,
|
||||
'platter': true,
|
||||
'rope_tow': true,
|
||||
'magic_carpet': true,
|
||||
'yes': true
|
||||
},
|
||||
'highway': {
|
||||
'motorway': true,
|
||||
'motorway_link': true
|
||||
},
|
||||
'junction': {
|
||||
'roundabout': true
|
||||
},
|
||||
'man_made': {
|
||||
'piste:halfpipe': true,
|
||||
'pipeline': true
|
||||
},
|
||||
'piste:type': {
|
||||
'downhill': true,
|
||||
'sled': true,
|
||||
'yes': true
|
||||
},
|
||||
'waterway': {
|
||||
'river': true,
|
||||
'stream': true
|
||||
}
|
||||
};
|
||||
+5
-5
@@ -48,11 +48,11 @@ _.extend(iD.Way.prototype, {
|
||||
if (['no', '0'].indexOf(this.tags.oneway) !== -1) { return false; }
|
||||
|
||||
// implied oneway tag..
|
||||
return this.tags.waterway === 'river' ||
|
||||
this.tags.waterway === 'stream' ||
|
||||
this.tags.highway === 'motorway' ||
|
||||
this.tags.highway === 'motorway_link' ||
|
||||
this.tags.junction === 'roundabout';
|
||||
for (var key in this.tags) {
|
||||
if (key in iD.oneWayTags && (this.tags[key] in iD.oneWayTags[key]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
isClosed: function() {
|
||||
|
||||
@@ -134,11 +134,13 @@ iD.ui.EntityEditor = function(context) {
|
||||
|
||||
function clean(o) {
|
||||
var out = {}, k, v;
|
||||
/*jshint -W083 */
|
||||
for (k in o) {
|
||||
if (k && (v = o[k]) !== undefined) {
|
||||
out[k] = v.trim();
|
||||
out[k] = v.split(';').map(function(s) { return s.trim(); }).join(';');
|
||||
}
|
||||
}
|
||||
/*jshint +W083 */
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
+38
-10
@@ -1,15 +1,38 @@
|
||||
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 = [],
|
||||
entity, 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) {
|
||||
// hack: pretend oneway field is a oneway_yes field
|
||||
// where implied oneway tag exists (e.g. `junction=roundabout`) #2220, #1841
|
||||
if (field.id === 'oneway') {
|
||||
for (var key in entity.tags) {
|
||||
if (key in iD.oneWayTags && (entity.tags[key] in iD.oneWayTags[key])) {
|
||||
texts.shift();
|
||||
texts.unshift(t('presets.fields.oneway_yes.check.undefined', { 'default': 'Assumed to be Yes' }));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selection.classed('checkselect', 'true');
|
||||
|
||||
label = selection.selectAll('.preset-input-wrap')
|
||||
@@ -24,7 +47,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')
|
||||
@@ -38,12 +61,17 @@ iD.ui.preset.defaultcheck = function(field) {
|
||||
text = label.select('span.value');
|
||||
};
|
||||
|
||||
check.entity = function(_) {
|
||||
if (!arguments.length) return entity;
|
||||
entity = _;
|
||||
return check;
|
||||
};
|
||||
|
||||
check.tags = function(tags) {
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ iD.ui.preset.typeCombo = function(field) {
|
||||
function options(opts) {
|
||||
combobox.data(opts.map(function(d) {
|
||||
var o = {};
|
||||
o.title = o.value = d.replace('_', ' ');
|
||||
o.title = o.value = d.replace(/_+/g, ' ');
|
||||
return o;
|
||||
}));
|
||||
|
||||
@@ -44,7 +44,12 @@ iD.ui.preset.typeCombo = function(field) {
|
||||
}
|
||||
|
||||
function change() {
|
||||
var value = input.value().replace(' ', '_');
|
||||
var value = input.value()
|
||||
.split(';')
|
||||
.map(function(s) { return s.trim(); })
|
||||
.join(';')
|
||||
.replace(/\s+/g, '_');
|
||||
|
||||
if (field.type === 'typeCombo' && !value) value = 'yes';
|
||||
|
||||
var t = {};
|
||||
|
||||
@@ -188,6 +188,7 @@
|
||||
<script src='../js/id/core/way.js'></script>
|
||||
<script src='../js/id/core/tree.js'></script>
|
||||
<script src='../js/id/core/area_keys.js'></script>
|
||||
<script src='../js/id/core/oneway_tags.js'></script>
|
||||
|
||||
<script src='../js/id/presets.js'></script>
|
||||
<script src='../js/id/presets/preset.js'></script>
|
||||
|
||||
Reference in New Issue
Block a user