mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Wipe out some tags entirely, refs #585
This commit is contained in:
@@ -108,5 +108,13 @@ iD.data.deprecated = [
|
||||
shop: 'supermarket',
|
||||
organic: 'only'
|
||||
}
|
||||
}
|
||||
},
|
||||
// entirely discarded tags
|
||||
{ old: { 'tiger:upload_uuid': '*' } },
|
||||
{ old: { 'tiger:tlid': '*' } },
|
||||
{ old: { 'tiger:source': '*' } },
|
||||
{ old: { 'tiger:separated': '*' } },
|
||||
{ old: { 'geobase:datasetName': '*' } },
|
||||
{ old: { 'geobase:uuid': '*' } },
|
||||
{ old: { 'sub_sea:type': '*' } }
|
||||
];
|
||||
|
||||
@@ -10,19 +10,19 @@ iD.actions.DeprecateTags = function(entityId) {
|
||||
|
||||
rule = iD.data.deprecated[i];
|
||||
var match = _.pairs(rule.old)[0],
|
||||
replacements = _.pairs(rule.replace);
|
||||
replacements = rule.replace ? _.pairs(rule.replace) : null;
|
||||
|
||||
if (entity.tags[match[0]] && match[1] === '*') {
|
||||
|
||||
var value = entity.tags[match[0]];
|
||||
if (!newtags[replacements[0][0]]) {
|
||||
if (replacements && !newtags[replacements[0][0]]) {
|
||||
newtags[replacements[0][0]] = value;
|
||||
}
|
||||
delete newtags[match[0]];
|
||||
change = true;
|
||||
|
||||
} else if (entity.tags[match[0]] === match[1]) {
|
||||
newtags = _.assign({}, rule.replace, _.omit(newtags, match[0]));
|
||||
newtags = _.assign({}, rule.replace || {}, _.omit(newtags, match[0]));
|
||||
change = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,13 @@ describe('iD.actions.DeprecateTags', function () {
|
||||
expect(graph.entity(entity.id).tags).to.eql(undeprecated);
|
||||
});
|
||||
|
||||
it('wipes out tags that should be entirely removed', function () {
|
||||
var entity = iD.Entity({ tags: { 'tiger:source': 'foo' } }),
|
||||
graph = iD.actions.DeprecateTags(entity.id)(iD.Graph([entity])),
|
||||
undeprecated = { };
|
||||
expect(graph.entity(entity.id).tags).to.eql(undeprecated);
|
||||
});
|
||||
|
||||
it('replaces keys', function () {
|
||||
var entity = iD.Entity({ tags: { power_rating: '1 billion volts' } }),
|
||||
graph = iD.actions.DeprecateTags(entity.id)(iD.Graph([entity])),
|
||||
|
||||
Reference in New Issue
Block a user