Fix tag updating

This commit is contained in:
Tom MacWright
2012-11-28 16:27:41 -05:00
parent 69de1df67b
commit f7d1a5eb72
2 changed files with 18 additions and 8 deletions
+2 -1
View File
@@ -374,7 +374,8 @@ iD.Map = function(elem, connection) {
}
inspector.on('changeTags', function(d, tags) {
map.perform(iD.actions.changeTags(d, tags));
var entity = map.history.graph().entity(d.id);
map.perform(iD.actions.changeTags(entity, tags));
}).on('changeWayDirection', function(d, tags) {
map.perform(iD.actions.changeWayDirection(d));
}).on('remove', function(d) {
+16 -7
View File
@@ -83,18 +83,27 @@ iD.Inspector = function() {
});
}
function update() {
function clean(x) {
for (var i in x) if (!i) delete x[i];
return x;
}
function pad(x) {
if (!x['']) x[''] = '';
return x;
}
function grabtags() {
var grabbed = {};
function grab(d) { grabbed[d.key] = d.value; }
tbody.selectAll('td').each(grab);
if (!grabbed['']) {
grabbed[''] = '';
draw(grabbed);
}
draw(grabbed);
return grabbed;
}
function update() {
draw(pad(grabtags()));
}
var data = _.clone(entity.tags);
draw(data);
update();
@@ -102,7 +111,7 @@ iD.Inspector = function() {
selection.append('button')
.attr('class', 'save').text('Save')
.on('click', function() {
event.changeTags(entity, update());
event.changeTags(entity, clean(grabtags()));
});
selection.append('button')