Only set defaults when preset chosen explicitly

This commit is contained in:
Ansis Brammanis
2013-02-23 20:51:10 -05:00
parent 7222fcb63f
commit 49ccbc5bda
2 changed files with 12 additions and 12 deletions

View File

@@ -41,14 +41,12 @@ iD.ui.preset = function() {
// generate form fields for a given field.
function input(d) {
var i, wrap,
default_ = d['default'] && d['default'][type];
var i, wrap;
switch (d.type) {
case 'text':
i = this.append('input')
.attr('type', 'text')
.attr('id', 'input-' + d.key)
.attr('placeholder', default_ || '');
.attr('id', 'input-' + d.key);
break;
case 'tel':
i = this.append('input')
@@ -71,12 +69,7 @@ iD.ui.preset = function() {
case 'check':
i = this.append('input')
.attr('type', 'checkbox')
.attr('id', 'input-' + d.key)
.each(function() {
if (default_) {
this.attr('checked', 'checked');
}
});
.attr('id', 'input-' + d.key);
break;
case 'select':
wrap = this.append('span').attr('class', 'input-wrap-position'),
@@ -87,7 +80,6 @@ iD.ui.preset = function() {
value: d
};
})));
if (default_) i.property('value', default_);
break;
case 'combo':
var combobox = d3.combobox();
@@ -102,7 +94,6 @@ iD.ui.preset = function() {
return d;
}));
});
if (default_) i.property('value', default_);
break;
}
if (i) {

View File

@@ -17,6 +17,7 @@ iD.ui.TagEditor = function() {
entity = selection.datum();
var type = entity.type === 'node' ? entity.type : entity.geometry();
// preset was explicitly chosen
if (preset) {
if (presetMatch) {
// Strip preset's match tags
@@ -35,6 +36,14 @@ iD.ui.TagEditor = function() {
for (var k in preset.match.tags) {
if (preset.match.tags[k] !== '*') tags[k] = preset.match.tags[k];
}
// Add new preset's defaults
for (var f in preset.form) {
f = preset.form[f];
if (f.key && !tags[f.key] && f['default'] && f['default'][type]) {
tags[f.key] = f['default'][type];
}
}
}
presetMatch = preset || presetMatch || presetData.matchTags(entity);