diff --git a/js/id/presetdata.js b/js/id/presetdata.js index 48aad7b00..de5274d39 100644 --- a/js/id/presetdata.js +++ b/js/id/presetdata.js @@ -1,16 +1,21 @@ iD.presetData = function() { var presets = {}, - data = []; + data = [], + defaults; presets.data = function(_) { if (!arguments.length) return data; - data = _; + data = _.presets; + defaults = _.defaults; return presets; }; - presets.favs = function() { - return data.filter(function(d) { - return d.favorite; + presets.defaults = function(entity) { + var type = entity.type == 'node' ? 'node' : entity.geometry(); + return defaults[type].map(function(def) { + return _.find(data, function(d) { + return d.name === def; + }); }); }; diff --git a/js/id/ui/presetgrid.js b/js/id/ui/presetgrid.js index 6ae7f00d8..db771b1ea 100644 --- a/js/id/ui/presetgrid.js +++ b/js/id/ui/presetgrid.js @@ -36,6 +36,8 @@ iD.ui.PresetGrid = function() { function filter(value) { + if (!value) return presetData.defaults(entity); + value = value.toLowerCase(); return viable.filter(function(v) { return v.name.toLowerCase().indexOf(value) !== -1; diff --git a/presets/presets.json b/presets/presets.json index 69cfc52c3..7c9ee6640 100644 --- a/presets/presets.json +++ b/presets/presets.json @@ -1,419 +1,715 @@ -[ - { - "title": "Building", - "name": "building", - "match": { - "type": ["area"], - "tags": { - "building": "*" - } - }, - "icon": "warehouse", - "form": [ - { - "key": "building", - "type": "combo", - "default": { - "area": "yes" - } - } - ] - }, - { - "title": "Cafe", - "name": "cafe", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "cafe" - } - }, - "icon": "cafe", - "form": [ - { - "key": "internet_access", - "title": "Internet Access", - "type": "select", - "options": ["yes", "no", "wlan", "wired", "terminal"] - }, - { - "key": "cuisine", - "type": "combo" - }, - { - "key": "building", - "type": "select", - "options": ["yes", "no"], - "default": { - "area": "yes" +{ + "presets": [ + { + "title": "Cafe", + "name": "cafe", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "cafe" } }, - { - "type": "address", - "title": "Address" - } - ] - }, - { - "title": "Park", - "name": "park", - "match": { - "type": ["node", "area"], - "tags": { - "leisure": "park" - } + "icon": "cafe", + "form": [ + { + "key": "cuisine", + "type": "combo" + }, + { + "key": "internet_access", + "title": "Internet Access", + "type": "select", + "options": ["yes", "no", "wlan", "wired", "terminal"] + }, + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] }, - "icon": "park", - "form": [] - }, - { - "title": "Water", - "name": "water", - "match": { - "type": ["node", "area"], - "tags": { - "natural": "water" - } - }, - "icon": "", - "form": [] - }, - { - "title": "Supermarket", - "name": "supermarket", - "match": { - "type": ["node", "area"], - "tags": { - "shop": "supermarket" - } - }, - "icon": "grocery", - "form": [ - { - "key": "operator", - "type": "text" - } - ] - }, - { - "title": "Restaurant", - "name": "restaurant", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "restaurant" - } - }, - "icon": "restaurant", - "form": [ - { - "key": "cuisine", - "type": "combo" - } - ] - }, - { - "title": "Place of worship", - "name": "place of worship", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "place_of_worship" - } - }, - "icon": "place-of-worship", - "form": [ - { - "key": "religion", - "type": "select", - "options": ["christian", "muslim", "buddhist", "jewish", "hindu", "shinto", "taoist"] + { + "title": "Park", + "name": "park", + "match": { + "type": ["node", "area"], + "tags": { + "leisure": "park" + } }, - { - "key": "denomination", - "type": "combo" - } - ] - }, - { - "title": "School", - "name": "school", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "school" - } + "icon": "park", + "form": [] }, - "icon": "school", - "form": [ - { - "key": "operator", - "type": "text" - } - ] - }, - { - "title": "Parking", - "name": "parking", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "parking" - } - }, - "icon": "parking", - "form": [ - { - "key": "fee", - "type": "select", - "options": ["yes", "no"] - } - ] - }, - { - "title": "Bank", - "name": "bank", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "bank" - } - }, - "icon": "bank", - "form": [ - { - "key": "atm", - "type": "select", - "options": ["yes", "no"] - } - ] - }, - { - "title": "Fast food", - "name": "fast food", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "fast_food" - } - }, - "icon": "fast-food", - "form": [ - { - "key": "cuisine", - "type": "combo" + { + "title": "Water", + "name": "water", + "match": { + "type": ["node", "area"], + "tags": { + "natural": "water" + } }, - { - "key": "monkey", - "type": "combo" - } + "icon": "", + "form": [] + }, + { + "title": "Supermarket", + "name": "supermarket", + "match": { + "type": ["node", "area"], + "tags": { + "shop": "supermarket" + } + }, + "icon": "grocery", + "form": [ + { + "key": "operator", + "type": "text" + }, + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "Restaurant", + "name": "restaurant", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "restaurant" + } + }, + "icon": "restaurant", + "form": [ + { + "key": "cuisine", + "type": "combo" + }, + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "Place of worship", + "name": "place of worship", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "place_of_worship" + } + }, + "icon": "place-of-worship", + "form": [ + { + "key": "religion", + "type": "select", + "options": ["christian", "muslim", "buddhist", "jewish", "hindu", "shinto", "taoist"] + }, + { + "key": "denomination", + "type": "combo" + }, + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "School", + "name": "school", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "school" + } + }, + "icon": "school", + "form": [ + { + "key": "operator", + "type": "text" + }, + { + "key": "building", + "type": "select", + "options": ["yes", "no"] + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "Parking", + "name": "parking", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "parking" + } + }, + "icon": "parking", + "form": [ + { + "key": "fee", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "Bank", + "name": "bank", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "bank" + } + }, + "icon": "bank", + "form": [ + { + "key": "atm", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "Fast food", + "name": "fast food", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "fast_food" + } + }, + "icon": "fast-food", + "form": [ + { + "key": "cuisine", + "type": "combo" + }, + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "Bar", + "name": "bar", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "bar" + } + }, + "icon": "bar", + "form": [ + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "Bus stop", + "name": "bus stop", + "match": { + "type": ["node"], + "tags": { + "highway": "bus_stop" + } + }, + "icon": "bus", + "form": [ + { + "key": "operator", + "type": "text" + }, + { + "key": "shelter", + "type": "select", + "options": ["yes", "no"] + } + ] + }, + { + "title": "Cinema", + "name": "cinema", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "cinema" + } + }, + "icon": "cinema", + "form": [ + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "Hospital", + "name": "hospital", + "match": { + "type": ["node", "area"], + "tags": { + "amenity": "hospital" + } + }, + "icon": "hospital", + "form": [ + { + "key": "emergency", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "River", + "name": "river", + "match": { + "type": ["line"], + "tags": { + "waterway": "river" + } + }, + "icon": "waterway-river", + "form": [] + }, + { + "title": "Motorway", + "name": "motorway", + "match": { + "type": ["line"], + "tags": { + "highway": "motorway" + } + }, + "icon": "highway-motorway", + "form": [ + { + "key": "oneway", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "key": "maxspeed", + "type": "combo" + } + ] + }, + { + "title": "Residential road", + "name": "residential road", + "match": { + "type": ["line"], + "tags": { + "highway": "residential" + } + }, + "icon": "highway-residential", + "form": [ + { + "key": "oneway", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "key": "maxspeed", + "type": "combo" + } + ] + }, + { + "title": "Primary Road", + "name": "primary road", + "match": { + "type": ["line"], + "tags": { + "highway": "primary" + } + }, + "icon": "highway-primary", + "form": [ + { + "key": "oneway", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "key": "maxspeed", + "type": "combo" + } + ] + }, + { + "title": "Secondary Road", + "name": "secondary road", + "match": { + "type": ["line"], + "tags": { + "highway": "secondary" + } + }, + "icon": "highway-secondary", + "form": [ + { + "key": "oneway", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "key": "maxspeed", + "type": "combo" + } + ] + }, + { + "title": "Tertiary Road", + "name": "tertiary road", + "match": { + "type": ["line"], + "tags": { + "highway": "tertiary" + } + }, + "icon": "highway-tertiary", + "form": [ + { + "key": "oneway", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "key": "maxspeed", + "type": "combo" + } + ] + }, + { + "title": "Service Road", + "name": "service road", + "match": { + "type": ["line"], + "tags": { + "highway": "service" + } + }, + "icon": "highway-service", + "form": [ + { + "key": "oneway", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "key": "maxspeed", + "type": "combo" + } + ] + }, + { + "title": "Rail", + "name": "rail", + "match": { + "type": ["line"], + "tags": { + "railway": "rail" + } + }, + "icon": "railway-rail", + "form": [] + }, + { + "title": "Trunk highway", + "name": "trunk highway", + "match": { + "type": ["line"], + "tags": { + "highway": "trunk" + } + }, + "icon": "highway-trunk", + "form": [ + { + "key": "oneway", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "key": "maxspeed", + "type": "combo" + } + ] + }, + { + "title": "Foot path", + "name": "foot path", + "match": { + "type": ["line"], + "tags": { + "highway": "footway" + } + }, + "icon": "highway-footway", + "form": [ + { + "key": "oneway", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "key": "maxspeed", + "type": "combo" + } + ] + }, + { + "title": "Cycle path", + "name": "cycle path", + "match": { + "type": ["line"], + "tags": { + "highway": "cycleway" + } + }, + "icon": "highway-cycleway", + "form": [ + { + "key": "oneway", + "type": "select", + "options": ["yes", "no"] + }, + { + "key": "access", + "type": "combo" + }, + { + "key": "maxspeed", + "type": "combo" + } + ] + }, + { + "title": "Building", + "name": "building", + "match": { + "type": ["area"], + "tags": { + "building": "*" + } + }, + "icon": "warehouse", + "form": [ + { + "key": "building", + "type": "combo", + "default": { + "area": "yes" + } + }, + { + "type": "address", + "title": "Address" + } + ] + }, + { + "title": "Other", + "name": "other", + "match": { + "type": ["line", "area"], + "tags": {} + }, + "icon": "square-stroked", + "form": [] + }, + { + "title": "Other", + "name": "other", + "match": { + "type": ["node"], + "tags": {} + }, + "icon": "marker-stroked", + "form": [] + } + ], + + "defaults": { + "area": [ + "building", + "park", + "water", + "parking", + "hospital", + "place of worship", + "cafe", + "restaurant", + "bar", + "fast food", + "bank", + "other" + ], + "line": [ + "residential road", + "primary road", + "secondary road", + "tertiary road", + "foot path", + "cycle path", + "motorway", + "trunk highway", + "service road", + "river", + "rail", + "other" + ], + "node": [ + "bus stop", + "park", + "hospital", + "place of worship", + "cafe", + "restaurant", + "bar", + "fast food", + "bank", + "cinema", + "supermarket", + "other" ] - }, - { - "title": "Bar", - "name": "bar", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "bar" - } - }, - "icon": "bar", - "form": [ - ] - }, - { - "title": "Bus stop", - "name": "bus stop", - "match": { - "type": ["node"], - "tags": { - "highway": "bus_stop" - } - }, - "icon": "bus", - "form": [ - { - "key": "operator", - "type": "text" - } - ] - }, - { - "title": "Cinema", - "name": "cinema", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "cinema" - } - }, - "icon": "cinema", - "form": [ - ] - }, - { - "title": "Hospital", - "name": "hospital", - "match": { - "type": ["node", "area"], - "tags": { - "amenity": "hospital" - } - }, - "icon": "hospital", - "form": [ - ] - }, - { - "title": "River", - "name": "river", - "match": { - "type": ["line"], - "tags": { - "waterway": "river" - } - }, - "icon": "waterway-river", - "form": [] - }, - { - "title": "Motorway", - "name": "motorway", - "match": { - "type": ["line"], - "tags": { - "highway": "motorway" - } - }, - "icon": "highway-motorway", - "form": [] - }, - { - "title": "Residential", - "name": "residential", - "match": { - "type": ["line"], - "tags": { - "highway": "residential" - } - }, - "icon": "highway-residential", - "form": [] - }, - { - "title": "Primary Road", - "name": "primary road", - "match": { - "type": ["line"], - "tags": { - "highway": "primary" - } - }, - "icon": "highway-primary", - "form": [] - }, - { - "title": "Secondary Road", - "name": "secondary road", - "match": { - "type": ["line"], - "tags": { - "highway": "secondary" - } - }, - "icon": "highway-secondary", - "form": [] - }, - { - "title": "Tertiary Road", - "name": "tertiary road", - "match": { - "type": ["line"], - "tags": { - "highway": "tertiary" - } - }, - "icon": "highway-tertiary", - "form": [] - }, - { - "title": "Service Road", - "name": "service road", - "match": { - "type": ["line"], - "tags": { - "highway": "service" - } - }, - "icon": "highway-service", - "form": [] - }, - { - "title": "Rail", - "name": "rail", - "match": { - "type": ["line"], - "tags": { - "railway": "rail" - } - }, - "icon": "railway-rail", - "form": [] - }, - { - "title": "Trunk highway", - "name": "trunk highway", - "match": { - "type": ["line"], - "tags": { - "highway": "trunk" - } - }, - "icon": "highway-trunk", - "form": [] - }, - { - "title": "Foot path", - "name": "foot path", - "match": { - "type": ["line"], - "tags": { - "highway": "footway" - } - }, - "icon": "highway-footway", - "form": [] - }, - { - "title": "Cycle path", - "name": "cycle path", - "match": { - "type": ["line"], - "tags": { - "highway": "cycleway" - } - }, - "icon": "highway-cycleway", - "form": [] - }, - { - "title": "Other", - "name": "other", - "match": { - "type": ["line", "area"], - "tags": {} - }, - "icon": "square-stroked", - "form": [] - }, - { - "title": "Other", - "name": "other", - "match": { - "type": ["node"], - "tags": {} - }, - "icon": "marker-stroked", - "form": [] } -] +}