Replace extend with smarter copy for tag changes

Because compound fields like `address` may send a bunch of undefined tag
values in the `changed` object, and we don't want them all to turn into
raw tags (but we do want them to override any existing tags).

This is subtlely different than what `_.extend({}, existing, changed)` did.
This commit is contained in:
Bryan Housel
2016-09-27 23:20:16 -04:00
parent b92e49f61a
commit 132e699c89

View File

@@ -208,11 +208,18 @@ export function EntityEditor(context) {
function changeTags(changed, onInput) {
var entity = context.entity(id),
annotation = t('operations.change_tags.annotation'),
tags = _.extend({}, entity.tags, changed);
tags = _.clone(entity.tags);
_.forEach(changed, function(v, k) {
if (v !== undefined || tags.hasOwnProperty(k)) {
tags[k] = v;
}
});
if (!onInput) {
tags = clean(tags);
}
if (!_.isEqual(entity.tags, tags)) {
if (coalesceChanges) {
context.overwrite(ChangeTags(id, tags), annotation);