Misc preset fixes and work

This commit is contained in:
Ansis Brammanis
2013-02-22 14:08:01 -05:00
parent bfa2844d42
commit 388fae28ad
6 changed files with 69 additions and 33 deletions
+1 -1
View File
@@ -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;
+6 -4
View File
@@ -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;
};
+1 -1
View File
@@ -104,7 +104,7 @@ iD.ui.preset = function() {
return d;
}));
});
if (default_) i.property('value', default_);
break;
}
if (i) {
+1
View File
@@ -74,6 +74,7 @@ iD.ui.PresetGrid = function() {
entered.append('span').attr('class','label').text(name);
entries.exit().remove();
entries.order();
}
presetgrid.presetData = function(_) {
+10 -16
View File
@@ -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);
+50 -11
View File
@@ -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": []
}
]