mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-24 09:04:02 +02:00
Support minValue/maxValue on numeric fields
Configure most numeric fields to avoid negative values (closes #5043)
This commit is contained in:
@@ -137,6 +137,7 @@
|
||||
"admin_level": {
|
||||
"key": "admin_level",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Admin Level"
|
||||
},
|
||||
"aerialway": {
|
||||
@@ -164,12 +165,14 @@
|
||||
"aerialway/capacity": {
|
||||
"key": "aerialway:capacity",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Capacity (per hour)",
|
||||
"placeholder": "500, 2500, 5000..."
|
||||
},
|
||||
"aerialway/duration": {
|
||||
"key": "aerialway:duration",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Duration (minutes)",
|
||||
"placeholder": "1, 2, 3..."
|
||||
},
|
||||
@@ -181,6 +184,7 @@
|
||||
"aerialway/occupancy": {
|
||||
"key": "aerialway:occupancy",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Occupancy",
|
||||
"placeholder": "2, 4, 8..."
|
||||
},
|
||||
@@ -362,6 +366,7 @@
|
||||
"cables": {
|
||||
"key": "cables",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Cables",
|
||||
"placeholder": "1, 2, 3..."
|
||||
},
|
||||
@@ -391,6 +396,7 @@
|
||||
"capacity": {
|
||||
"key": "capacity",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Capacity",
|
||||
"placeholder": "50, 100, 200..."
|
||||
},
|
||||
@@ -582,6 +588,7 @@
|
||||
"devices": {
|
||||
"key": "devices",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Devices",
|
||||
"placeholder": "1, 2, 3..."
|
||||
},
|
||||
@@ -744,6 +751,7 @@
|
||||
"faces": {
|
||||
"key": "faces",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Faces"
|
||||
},
|
||||
"fax": {
|
||||
@@ -906,6 +914,7 @@
|
||||
},
|
||||
"height": {
|
||||
"key": "height",
|
||||
"minValue": 0,
|
||||
"type": "number",
|
||||
"label": "Height (Meters)"
|
||||
},
|
||||
@@ -927,6 +936,7 @@
|
||||
"hoops": {
|
||||
"key": "hoops",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Hoops",
|
||||
"placeholder": "1, 2, 4..."
|
||||
},
|
||||
@@ -1089,6 +1099,7 @@
|
||||
"lanes": {
|
||||
"key": "lanes",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Lanes",
|
||||
"placeholder": "1, 2, 3..."
|
||||
},
|
||||
@@ -1158,6 +1169,7 @@
|
||||
"length": {
|
||||
"key": "length",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Length (Meters)"
|
||||
},
|
||||
"level": {
|
||||
@@ -1169,6 +1181,7 @@
|
||||
"levels": {
|
||||
"key": "building:levels",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Levels",
|
||||
"placeholder": "2, 4, 6..."
|
||||
},
|
||||
@@ -1427,6 +1440,7 @@
|
||||
"par": {
|
||||
"key": "par",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Par",
|
||||
"placeholder": "3, 4, 5..."
|
||||
},
|
||||
@@ -1460,6 +1474,7 @@
|
||||
"phases": {
|
||||
"key": "phases",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Phases",
|
||||
"placeholder": "1, 2, 3..."
|
||||
},
|
||||
@@ -1545,11 +1560,13 @@
|
||||
"playground/max_age": {
|
||||
"key": "max_age",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Maximum Age"
|
||||
},
|
||||
"playground/min_age": {
|
||||
"key": "min_age",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Minimum Age"
|
||||
},
|
||||
"population": {
|
||||
@@ -1696,6 +1713,7 @@
|
||||
"rooms": {
|
||||
"key": "rooms",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Rooms"
|
||||
},
|
||||
"route_master": {
|
||||
@@ -1909,6 +1927,7 @@
|
||||
"stars": {
|
||||
"key": "stars",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Stars"
|
||||
},
|
||||
"start_date": {
|
||||
@@ -1920,6 +1939,7 @@
|
||||
"step_count": {
|
||||
"key": "step_count",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Number of Steps"
|
||||
},
|
||||
"stop": {
|
||||
@@ -2312,6 +2332,7 @@
|
||||
"width": {
|
||||
"key": "width",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Width (Meters)"
|
||||
},
|
||||
"wikipedia": {
|
||||
@@ -2328,6 +2349,7 @@
|
||||
"windings": {
|
||||
"key": "windings",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Windings",
|
||||
"placeholder": "1, 2, 3..."
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "admin_level",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Admin Level"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "aerialway:capacity",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Capacity (per hour)",
|
||||
"placeholder": "500, 2500, 5000..."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "aerialway:duration",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Duration (minutes)",
|
||||
"placeholder": "1, 2, 3..."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "aerialway:occupancy",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Occupancy",
|
||||
"placeholder": "2, 4, 8..."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "cables",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Cables",
|
||||
"placeholder": "1, 2, 3..."
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "capacity",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Capacity",
|
||||
"placeholder": "50, 100, 200..."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "devices",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Devices",
|
||||
"placeholder": "1, 2, 3..."
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "faces",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Faces"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
"type": "number",
|
||||
"label": "Handicap",
|
||||
"placeholder": "1-18"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "height",
|
||||
"minValue": 0,
|
||||
"type": "number",
|
||||
"label": "Height (Meters)"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "hoops",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Hoops",
|
||||
"placeholder": "1, 2, 4..."
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "lanes",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Lanes",
|
||||
"placeholder":"1, 2, 3..."
|
||||
"placeholder": "1, 2, 3..."
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "length",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Length (Meters)"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "building:levels",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Levels",
|
||||
"placeholder": "2, 4, 6..."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "par",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Par",
|
||||
"placeholder": "3, 4, 5..."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "phases",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Phases",
|
||||
"placeholder": "1, 2, 3..."
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "max_age",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Maximum Age"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "min_age",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Minimum Age"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "rooms",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Rooms"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "stars",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Stars"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "step_count",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Number of Steps"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"key": "width",
|
||||
"type": "number",
|
||||
"minValue": 0,
|
||||
"label": "Width (Meters)"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"key": "windings",
|
||||
"type": "number",
|
||||
"minValue": 1,
|
||||
"label": "Windings",
|
||||
"placeholder": "1, 2, 3..."
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"options": {
|
||||
"description": "List of untranslatable string suggestions (combo type fields)",
|
||||
"description": "List of untranslatable string suggestions (combo fields)",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -108,18 +108,26 @@
|
||||
"type": "string"
|
||||
},
|
||||
"strings": {
|
||||
"description": "Translatable strings options (combo type fields)",
|
||||
"description": "Translatable strings options (combo fields)",
|
||||
"type": "object"
|
||||
},
|
||||
"snake_case": {
|
||||
"description": "If true, replace spaces with underscores in the tag value (combo type fields)",
|
||||
"description": "If true, replace spaces with underscores in the tag value (combo fields only)",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"caseSensitive": {
|
||||
"description": "If true, allow case sensitive field values (combo type fields)",
|
||||
"description": "If true, allow case sensitive field values (combo fields only)",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"minValue": {
|
||||
"description": "Minimum field value (number fields only)",
|
||||
"type": "integer"
|
||||
},
|
||||
"maxValue": {
|
||||
"description": "Maximum field value (number fields only)",
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
||||
@@ -20,10 +20,10 @@ export {
|
||||
|
||||
|
||||
export function uiFieldText(field, context) {
|
||||
var dispatch = d3_dispatch('change'),
|
||||
nominatim = services.geocoder,
|
||||
input,
|
||||
entity;
|
||||
var dispatch = d3_dispatch('change');
|
||||
var nominatim = services.geocoder;
|
||||
var input;
|
||||
var entity;
|
||||
|
||||
|
||||
function i(selection) {
|
||||
@@ -84,7 +84,20 @@ export function uiFieldText(field, context) {
|
||||
.on('click', function(d) {
|
||||
d3_event.preventDefault();
|
||||
var num = parseInt(input.node().value || 0, 10);
|
||||
if (!isNaN(num)) input.node().value = num + d;
|
||||
if (isNaN(num)) {
|
||||
num = 0;
|
||||
}
|
||||
|
||||
num = num + d;
|
||||
|
||||
if (field.minValue !== undefined) {
|
||||
num = Math.max(num, field.minValue);
|
||||
}
|
||||
if (field.maxValue !== undefined) {
|
||||
num = Math.min(num, field.maxValue);
|
||||
}
|
||||
|
||||
input.node().value = num;
|
||||
change()();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user