mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Deprecate vending=parcel_mail_in;parcel_pickup -> vending=parcel_pickup;parcel_mail_in (close #7988)
Enable upgrading of entire semicolon-delimited values
This commit is contained in:
@@ -1558,6 +1558,10 @@
|
||||
"old": {"unnamed": "*"},
|
||||
"replace": {"noname": "$1"}
|
||||
},
|
||||
{
|
||||
"old": {"vending": "parcel_mail_in;parcel_pickup"},
|
||||
"replace": {"vending": "parcel_pickup;parcel_mail_in"}
|
||||
},
|
||||
{
|
||||
"old": {"vhf_channel": "*"},
|
||||
"replace": {"vhf": "$1"}
|
||||
|
||||
@@ -2366,6 +2366,7 @@
|
||||
{"key": "type", "value": "shield", "description": "🄳 ➜ volcano:type=shield"},
|
||||
{"key": "type", "value": "strato", "description": "🄳 ➜ volcano:type=stratovolcano"},
|
||||
{"key": "unnamed", "description": "🄳 ➜ noname=*"},
|
||||
{"key": "vending", "value": "parcel_mail_in;parcel_pickup", "description": "🄳 ➜ vending=parcel_pickup;parcel_mail_in"},
|
||||
{"key": "vhf_channel", "description": "🄳 ➜ vhf=*"},
|
||||
{"key": "volcano", "value": "extinct", "description": "🄳 ➜ volcano:status=extinct"},
|
||||
{"key": "wall_type", "value": "noise_barrier", "description": "🄳 ➜ wall=noise_barrier"},
|
||||
|
||||
@@ -7,9 +7,15 @@ export function actionUpgradeTags(entityId, oldTags, replaceTags) {
|
||||
var semiIndex;
|
||||
|
||||
for (var oldTagKey in oldTags) {
|
||||
// wildcard match
|
||||
if (oldTags[oldTagKey] === '*') {
|
||||
// note the value since we might need to transfer it
|
||||
transferValue = tags[oldTagKey];
|
||||
delete tags[oldTagKey];
|
||||
// exact match
|
||||
} else if (oldTags[oldTagKey] === tags[oldTagKey]) {
|
||||
delete tags[oldTagKey];
|
||||
// match is within semicolon-delimited values
|
||||
} else {
|
||||
var vals = tags[oldTagKey].split(';').filter(Boolean);
|
||||
var oldIndex = vals.indexOf(oldTags[oldTagKey]);
|
||||
|
||||
@@ -201,6 +201,7 @@ osmEntity.prototype = {
|
||||
var matchesDeprecatedTags = oldKeys.every(function(oldKey) {
|
||||
if (!tags[oldKey]) return false;
|
||||
if (d.old[oldKey] === '*') return true;
|
||||
if (d.old[oldKey] === tags[oldKey]) return true;
|
||||
|
||||
var vals = tags[oldKey].split(';').filter(Boolean);
|
||||
if (vals.length === 0) {
|
||||
|
||||
@@ -96,4 +96,12 @@ describe('iD.actionUpgradeTags', function () {
|
||||
expect(graph.entity(entity.id).tags).to.eql({ leisure: 'ice_rink', sport: 'curling;ice_hockey;multi', name: 'Foo' });
|
||||
});
|
||||
|
||||
it('upgrades an entire semicolon-delimited tag value', function () {
|
||||
var oldTags = { vending: 'parcel_mail_in;parcel_pickup' },
|
||||
newTags = { vending: 'parcel_pickup;parcel_mail_in' },
|
||||
entity = iD.osmEntity({ tags: { vending: 'parcel_mail_in;parcel_pickup', name: 'Foo' }}),
|
||||
graph = iD.actionUpgradeTags(entity.id, oldTags, newTags)(iD.coreGraph([entity]));
|
||||
expect(graph.entity(entity.id).tags).to.eql({ vending: 'parcel_pickup;parcel_mail_in', name: 'Foo' });
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user