don't inherit fields for tags that the preset already has a field for

this is useful if a preset wants to inherit some fields from another preset, but wants to replace some of the fields with special versions of the field (e.g. a `…_yes` field for an added default value), or to change the `fields`/`moreFields` classification of a field
This commit is contained in:
Martin Raifer
2025-03-16 13:48:31 +01:00
parent e6c379053e
commit 78f94632d7
2 changed files with 9 additions and 2 deletions
+2
View File
@@ -49,6 +49,8 @@ _Breaking developer changes, which may affect downstream projects or sites that
#### :earth_asia: Localization
#### :hourglass: Performance
#### :mortar_board: Walkthrough / Help
#### :rocket: Presets
* Don't inherit fields which the current preset already has a dedicated field for
#### :hammer: Development
[#10805]: https://github.com/openstreetmap/iD/pull/10805
+7 -2
View File
@@ -325,7 +325,7 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) {
}
}
return utilArrayUniq(resolved);
return resolved;
// returns an array of fields to inherit from the given presetID, if found
@@ -335,7 +335,7 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) {
if (which === 'fields') {
return parent.fields().filter(shouldInherit);
} else if (which === 'moreFields') {
return parent.moreFields();
return parent.moreFields().filter(shouldInherit);
} else {
return [];
}
@@ -349,6 +349,11 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) {
// inherit anyway if multiple values are allowed or just a checkbox
f.type !== 'multiCombo' && f.type !== 'semiCombo' && f.type !== 'manyCombo' && f.type !== 'check'
) return false;
if (f.key && (_this.originalFields.some(originalField => f.key === allFields[originalField]?.key)
|| _this.originalMoreFields.some(originalField => f.key === allFields[originalField]?.key))) {
// current preset already has a field for this field
return false;
}
return true;
}