mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-05 14:38:05 +02:00
Merge branch 'master' into validation
This commit is contained in:
+34
-4
@@ -48,10 +48,12 @@ export function uiField(context, presetField, entity, options) {
|
||||
dispatch.call('change', field, t, onInput);
|
||||
});
|
||||
|
||||
// if this field cares about the entity, pass it along
|
||||
if (entity && field.impl.entity) {
|
||||
if (entity) {
|
||||
field.entityID = entity.id;
|
||||
field.impl.entity(entity);
|
||||
// if this field cares about the entity, pass it along
|
||||
if (field.impl.entity) {
|
||||
field.impl.entity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,11 +231,39 @@ export function uiField(context, presetField, entity, options) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// A shown field has a visible UI, a non-shown field is in the 'Add field' dropdown
|
||||
field.isShown = function() {
|
||||
return _show || isPresent();
|
||||
};
|
||||
|
||||
// An allowed field can appear in the UI or in the 'Add field' dropdown.
|
||||
// A non-allowed field is hidden from the user altogether
|
||||
field.isAllowed = function() {
|
||||
|
||||
if (isPresent()) {
|
||||
// always allow a field with a value to display
|
||||
return true;
|
||||
}
|
||||
|
||||
var prerequisiteTag = field.prerequisiteTag;
|
||||
if (prerequisiteTag && field.entityID) {
|
||||
if (prerequisiteTag.key) {
|
||||
var value = context.graph().entity(field.entityID).tags[prerequisiteTag.key];
|
||||
if (value) {
|
||||
if (prerequisiteTag.valueNot) {
|
||||
return prerequisiteTag.valueNot !== value;
|
||||
}
|
||||
if (prerequisiteTag.value) {
|
||||
return prerequisiteTag.value === value;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
field.focus = function() {
|
||||
if (field.impl) {
|
||||
|
||||
@@ -16,9 +16,18 @@ export function uiFormFields(context) {
|
||||
}
|
||||
|
||||
|
||||
formFields.tagsChanged = function() {};
|
||||
|
||||
function render(selection, klass) {
|
||||
var shown = _fieldsArr.filter(function(field) { return field.isShown(); });
|
||||
var notShown = _fieldsArr.filter(function(field) { return !field.isShown(); });
|
||||
|
||||
formFields.tagsChanged = function() {
|
||||
render(selection, klass);
|
||||
};
|
||||
|
||||
var allowedFields = _fieldsArr.filter(function(field) { return field.isAllowed(); });
|
||||
|
||||
var shown = allowedFields.filter(function(field) { return field.isShown(); });
|
||||
var notShown = allowedFields.filter(function(field) { return !field.isShown(); });
|
||||
|
||||
var container = selection.selectAll('.form-fields-container')
|
||||
.data([0]);
|
||||
|
||||
@@ -120,6 +120,7 @@ export function uiPresetEditor(context) {
|
||||
presetEditor.tags = function(val) {
|
||||
if (!arguments.length) return _tags;
|
||||
_tags = val;
|
||||
formFields.tagsChanged();
|
||||
// Don't reset _fieldsArr here.
|
||||
return presetEditor;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user