mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-25 17:37:49 +02:00
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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user