Make field reference more flexible

Will need to support {"rtype": "restriction"} for turn
restriction field.
This commit is contained in:
John Firebaugh
2014-05-14 17:22:24 -07:00
parent 4261fefc6e
commit cb1972d76f
5 changed files with 38 additions and 9 deletions

View File

@@ -7,7 +7,9 @@
"bicycle",
"horse"
],
"referenceKey": "access",
"reference": {
"key": "access"
},
"type": "access",
"label": "Access",
"placeholder": "Unknown",
@@ -66,7 +68,9 @@
"addr:city",
"addr:postcode"
],
"referenceKey": "addr",
"reference": {
"key": "addr"
},
"icon": "address",
"universal": true,
"label": "Address",

View File

@@ -1,6 +1,6 @@
{
"keys": ["access", "foot", "motor_vehicle", "bicycle", "horse"],
"referenceKey": "access",
"reference": {"key": "access"},
"type": "access",
"label": "Access",
"placeholder": "Unknown",

View File

@@ -6,7 +6,7 @@
"addr:city",
"addr:postcode"
],
"referenceKey": "addr",
"reference": {"key": "addr"},
"icon": "address",
"universal": true,
"label": "Address",

View File

@@ -14,9 +14,35 @@
"type": "string"
}
},
"referenceKey": {
"description": "Tag key which should be used to get taginfo documentation for (to be used when a field manages multiple tags)",
"type": "string"
"reference": {
"description": "Taginfo documentation parameters (to be used when a field manages multiple tags)",
"type": [
{
"type": "object",
"properties": {
"key": {
"description": "For documentation of a key",
"type": "string",
"required": true
},
"value": {
"description": "For documentation of a tag (key and value)",
"type": "string"
}
},
"additionalProperties": false
},
{
"type": "object",
"properties": {
"rtype": {
"description": "For documentation of a relation type",
"type": "string"
}
},
"additionalProperties": false
}
]
},
"type": {
"description": "Type of field",

View File

@@ -134,8 +134,7 @@ iD.ui.preset = function(context) {
return field.present();
})
.each(function(field) {
var key = field.referenceKey || field.key,
reference = iD.ui.TagReference({key: key});
var reference = iD.ui.TagReference(field.reference || {key: field.key});
if (state === 'hover') {
reference.showing(false);