diff --git a/css/app.css b/css/app.css index ff9a8a15b..bc8133df4 100644 --- a/css/app.css +++ b/css/app.css @@ -110,6 +110,7 @@ a:hover { textarea, input[type=text], +input[type=search], input[type=url], input[type=tel], input[type=email] { @@ -814,7 +815,6 @@ div.combobox { /* Preset icon colors */ -.preset-icon-fill.tag-amenity, .preset-icon-fill.tag-shop, .preset-icon-fill.tag-building { background-color: #e06e5f; diff --git a/js/id/presetdata.js b/js/id/presetdata.js index aa3752283..48aad7b00 100644 --- a/js/id/presetdata.js +++ b/js/id/presetdata.js @@ -23,17 +23,19 @@ iD.presetData = function() { presets.matchTags = function(entity) { var tags, count, best, - maxcount = 0, + maxcount = -1, type = entity.type == 'node' ? 'node' : entity.geometry(); for (var i = 0; i < data.length; i++) { count = 0; tags = data[i].match.tags; - if (!_.contains(data[i].match.type, type)) continue; for (var k in tags) { - if (entity.tags[k] == tags[k]) count++; + if (entity.tags[k] == tags[k] || (tags[k] === '*' && entity.tags[k])) count++; + else break; + } + if (Object.keys(tags).length === count && count > maxcount) { + best = data[i], maxcount = count; } - if (count > maxcount) best = data[i], maxcount = count; } return best; }; diff --git a/js/id/ui/preset.js b/js/id/ui/preset.js index ebb2505c6..c49daa6bc 100644 --- a/js/id/ui/preset.js +++ b/js/id/ui/preset.js @@ -104,7 +104,7 @@ iD.ui.preset = function() { return d; })); }); - + if (default_) i.property('value', default_); break; } if (i) { diff --git a/js/id/ui/presetgrid.js b/js/id/ui/presetgrid.js index 3f3c3d330..6ae7f00d8 100644 --- a/js/id/ui/presetgrid.js +++ b/js/id/ui/presetgrid.js @@ -74,6 +74,7 @@ iD.ui.PresetGrid = function() { entered.append('span').attr('class','label').text(name); entries.exit().remove(); + entries.order(); } presetgrid.presetData = function(_) { diff --git a/js/id/ui/tageditor.js b/js/id/ui/tageditor.js index 734340aa9..1a849921e 100644 --- a/js/id/ui/tageditor.js +++ b/js/id/ui/tageditor.js @@ -32,7 +32,9 @@ iD.ui.TagEditor = function() { } // Add new preset's match tags - tags = _.extend(tags, preset.match.tags); + for (var k in preset.match.tags) { + if (preset.match.tags[k] !== '*') tags[k] = preset.match.tags[k]; + } } presetMatch = preset || presetMatch || presetData.matchTags(entity); @@ -69,21 +71,16 @@ iD.ui.TagEditor = function() { typelabel.append('span') .attr('class','label') - .text(presetMatch ? presetMatch.name : 'Unknown type'); + .text(presetMatch ? presetMatch.name : 'Other'); namewrap.append('h4').text('Name'); name = namewrap.append('input') - .attr('placeholder', 'unkown') + .attr('placeholder', 'unknown') .attr('class', 'major') .attr('type', 'text') - .property('value', function() { - return entity.tags.name || ''; - }) + .property('value', entity.tags.name || 'this') .on('blur', function() { - var tags = tageditor.tags(); - tags.name = this.value; - tageditor.tags(tags); event.change(); }); @@ -93,11 +90,6 @@ iD.ui.TagEditor = function() { .append('span') .attr('class', 'icon inspect'); - event.on('change.name', function() { - var tags = tageditor.tags(); - name.property('value', tags.name); - }); - presetUI = iD.ui.preset() .context(context) .entity(entity) @@ -140,9 +132,11 @@ iD.ui.TagEditor = function() { tageditor.tags = function(newtags) { if (!arguments.length) { - return _.extend(presetUI.tags(), tagList.tags(), { name: name.property('value') }); + tags = _.extend(presetUI.tags(), tagList.tags()); + if (name.property('value')) tags.name = name.property('value'); + return tags; } else { - tags = newtags; + tags = _.clone(newtags); if (presetUI && tagList) { name.property('value', tags.name || ''); presetUI.change(tags); diff --git a/presets/presets.json b/presets/presets.json index 2fffd021c..69cfc52c3 100644 --- a/presets/presets.json +++ b/presets/presets.json @@ -1,4 +1,24 @@ [ + { + "title": "Building", + "name": "building", + "match": { + "type": ["area"], + "tags": { + "building": "*" + } + }, + "icon": "warehouse", + "form": [ + { + "key": "building", + "type": "combo", + "default": { + "area": "yes" + } + } + ] + }, { "title": "Cafe", "name": "cafe", @@ -10,15 +30,6 @@ }, "icon": "cafe", "form": [ - { - "key": "building", - "type": "select", - "options": ["yes", "no"], - "default": { - "area": "yes", - "node": "no" - } - }, { "key": "internet_access", "title": "Internet Access", @@ -29,6 +40,14 @@ "key": "cuisine", "type": "combo" }, + { + "key": "building", + "type": "select", + "options": ["yes", "no"], + "default": { + "area": "yes" + } + }, { "type": "address", "title": "Address" @@ -102,7 +121,7 @@ "amenity": "place_of_worship" } }, - "icon": "", + "icon": "place-of-worship", "form": [ { "key": "religion", @@ -206,7 +225,7 @@ "title": "Bus stop", "name": "bus stop", "match": { - "type": ["node", "area"], + "type": ["node"], "tags": { "highway": "bus_stop" } @@ -376,5 +395,25 @@ }, "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": [] } ]