mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 21:28:11 +02:00
on preset change: don't drop tags if ∃ a matching field in the new preset
closes #9341 closes #9104
This commit is contained in:
@@ -46,6 +46,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
#### :bug: Bugfixes
|
||||
* Fix selection of best background source when starting on a zoomed-out view ([#9325])
|
||||
* Fix leaking of localized strings in combo fields when taginfo service is unavailable ([#9342])
|
||||
* Keep tags when changing presets if the new preset has a field for it ([#9341], [#9104])
|
||||
#### :rocket: Presets
|
||||
* Support tagging schema v5 ([#9320]):
|
||||
* Add new field type `colour` ([schema-builder#38], [#8782])
|
||||
@@ -56,9 +57,11 @@ _Breaking developer changes, which may affect downstream projects or sites that
|
||||
* Make settings like CDN and API urls configurable in a central config file (`/config/is.js`)
|
||||
|
||||
[#8105]: https://github.com/openstreetmap/iD/issues/8105
|
||||
[#9104]: https://github.com/openstreetmap/iD/issues/9104
|
||||
[#9294]: https://github.com/openstreetmap/iD/issues/9294
|
||||
[#9320]: https://github.com/openstreetmap/iD/pull/9320
|
||||
[#9325]: https://github.com/openstreetmap/iD/issues/9325
|
||||
[#9341]: https://github.com/openstreetmap/iD/issues/9341
|
||||
[#9342]: https://github.com/openstreetmap/iD/issues/9342
|
||||
[schema-builder#38]: https://github.com/ideditor/schema-builder/pull/38
|
||||
|
||||
|
||||
@@ -5,7 +5,18 @@ export function actionChangePreset(entityID, oldPreset, newPreset, skipFieldDefa
|
||||
var tags = entity.tags;
|
||||
|
||||
// preserve tags that the new preset might care about, if any
|
||||
if (oldPreset) tags = oldPreset.unsetTags(tags, geometry, newPreset && newPreset.addTags ? Object.keys(newPreset.addTags) : null);
|
||||
var preserveKeys;
|
||||
if (newPreset) {
|
||||
preserveKeys = [];
|
||||
if (newPreset.addTags) {
|
||||
preserveKeys = preserveKeys.concat(Object.keys(newPreset.addTags));
|
||||
}
|
||||
newPreset.fields().concat(newPreset.moreFields())
|
||||
.filter(f => f.matchGeometry(geometry))
|
||||
.map(f => f.key).filter(Boolean)
|
||||
.forEach(key => preserveKeys.push(key));
|
||||
}
|
||||
if (oldPreset) tags = oldPreset.unsetTags(tags, geometry, preserveKeys);
|
||||
if (newPreset) tags = newPreset.setTags(tags, geometry, skipFieldDefaults);
|
||||
|
||||
return graph.replace(entity.update({tags: tags}));
|
||||
|
||||
@@ -226,7 +226,9 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) {
|
||||
|
||||
if (geometry && !skipFieldDefaults) {
|
||||
_this.fields().forEach(field => {
|
||||
if (field.matchGeometry(geometry) && field.key && field.default === tags[field.key]) {
|
||||
if (field.matchGeometry(geometry) && field.key &&
|
||||
field.default === tags[field.key] &&
|
||||
ignoringKeys.indexOf(field.key) !== -1) {
|
||||
delete tags[field.key];
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user