mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
use all available option strings when setting value
this fixes where tag values of fields with referenced strings can become corrupted when the sub-field has restricted `options`, and an unavailable option is entered manually into the field. important for openstreetmap/id-tagging-schema#891
This commit is contained in:
@@ -73,7 +73,7 @@ export function uiFieldCombo(field, context) {
|
||||
function tagValue(dval) {
|
||||
dval = clean(dval || '');
|
||||
|
||||
var found = getOptions().find(function(o) {
|
||||
var found = getOptions(true).find(function(o) {
|
||||
return o.key && clean(o.value) === dval;
|
||||
});
|
||||
if (found) return found.key;
|
||||
@@ -171,11 +171,17 @@ export function uiFieldCombo(field, context) {
|
||||
}
|
||||
}
|
||||
|
||||
function getOptions() {
|
||||
function getOptions(allOptions) {
|
||||
var stringsField = field.resolveReference('stringsCrossReference');
|
||||
if (!(field.options || stringsField.options)) return [];
|
||||
|
||||
return (field.options || stringsField.options).map(function(v) {
|
||||
let options;
|
||||
if (allOptions !== true) {
|
||||
options = field.options || stringsField.options;
|
||||
} else {
|
||||
options = [].concat(field.options, stringsField.options).filter(Boolean);
|
||||
}
|
||||
return options.map(function(v) {
|
||||
const labelId = getLabelId(stringsField, v);
|
||||
return {
|
||||
key: v,
|
||||
|
||||
Reference in New Issue
Block a user