mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 05:49:16 +02:00
uiField now dispatches own events
This commit is contained in:
+5
-3
@@ -4,10 +4,12 @@ import { textDirection } from '../util/locale';
|
||||
import { svgIcon } from '../svg';
|
||||
import { uiFields } from './fields';
|
||||
import { uiTagReference } from './tag_reference';
|
||||
import { utilRebind } from '../util';
|
||||
|
||||
|
||||
export function uiField(context, dispatch, presetField, entity, show) {
|
||||
var field = _.clone(presetField),
|
||||
export function uiField(context, presetField, entity, show) {
|
||||
var dispatch = d3.dispatch('change'),
|
||||
field = _.clone(presetField),
|
||||
tags;
|
||||
|
||||
|
||||
@@ -157,6 +159,6 @@ export function uiField(context, dispatch, presetField, entity, show) {
|
||||
};
|
||||
|
||||
|
||||
return field;
|
||||
return utilRebind(field, dispatch, 'on');
|
||||
}
|
||||
|
||||
|
||||
@@ -47,24 +47,32 @@ export function uiPresetEditor(context) {
|
||||
preset.fields.forEach(function(field) {
|
||||
if (field.matchGeometry(geometry)) {
|
||||
fieldsArr.push(
|
||||
uiField(context, dispatch, field, entity, true).tags(tags)
|
||||
uiField(context, field, entity, true)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (entity.isHighwayIntersection(context.graph()) && presets.field('restrictions')) {
|
||||
fieldsArr.push(
|
||||
uiField(context, dispatch, presets.field('restrictions'), entity, true).tags(tags)
|
||||
uiField(context, presets.field('restrictions'), entity, true)
|
||||
);
|
||||
}
|
||||
|
||||
presets.universal().forEach(function(field) {
|
||||
if (preset.fields.indexOf(field) === -1) {
|
||||
fieldsArr.push(
|
||||
uiField(context, dispatch, field, entity).tags(tags)
|
||||
uiField(context, field, entity)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
fieldsArr.forEach(function(field) {
|
||||
field
|
||||
.tags(tags)
|
||||
.on('change', function(t, onInput) {
|
||||
dispatch.call('change', field, t, onInput);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var shown = fieldsArr.filter(function(field) { return field.isShown(); }),
|
||||
|
||||
Reference in New Issue
Block a user