Rename uiPreset -> uiPresetEditor

(consistent with raw tag editor, raw member editor, etc)
This commit is contained in:
Bryan Housel
2017-08-02 17:49:02 -04:00
parent ce12c34efe
commit f6e76665a0
4 changed files with 17 additions and 70 deletions
+1
View File
@@ -37,6 +37,7 @@ export { rendererFeatures as Features } from './renderer/features';
export { rendererMap as Map } from './renderer/map';
export { rendererTileLayer as TileLayer } from './renderer/tile_layer';
export { utilDetect as Detect } from './util/detect';
export { uiPresetEditor as uiPreset } from './ui/preset_editor';
export var debug = false;
+2 -2
View File
@@ -10,7 +10,7 @@ import { uiRawMemberEditor } from './raw_member_editor';
import { uiRawMembershipEditor } from './raw_membership_editor';
import { uiRawTagEditor } from './raw_tag_editor';
import { uiTagReference } from './tag_reference';
import { uiPreset } from './preset';
import { uiPresetEditor } from './preset_editor';
import { utilRebind } from '../util';
@@ -24,7 +24,7 @@ export function uiEntityEditor(context) {
activePreset,
reference;
var presetEditor = uiPreset(context)
var presetEditor = uiPresetEditor(context)
.on('change', changeTags);
var rawTagEditor = uiRawTagEditor(context)
.on('change', changeTags);
+1 -1
View File
@@ -27,7 +27,7 @@ export { uiMapInMap } from './map_in_map';
export { uiModal } from './modal';
export { uiModes } from './modes';
export { uiNotice } from './notice';
export { uiPreset } from './preset';
export { uiPresetEditor } from './preset_editor';
export { uiPresetIcon } from './preset_icon';
export { uiPresetList } from './preset_list';
export { uiRadialMenu } from './radial_menu';
@@ -14,7 +14,7 @@ import {
} from '../util';
export function uiPreset(context) {
export function uiPresetEditor(context) {
var dispatch = d3.dispatch('change'),
expandedPreference = (context.storage('preset_fields.expanded') !== 'false'),
state,
@@ -24,61 +24,7 @@ export function uiPreset(context) {
id;
// // Field Constructor
// function UIField(field, entity, show) {
// field = _.clone(field);
// field.input = uiFields[field.type](field, context)
// .on('change', function(t, onInput) {
// dispatch.call('change', field, t, onInput);
// });
// if (field.input.entity) field.input.entity(entity);
// field.keys = field.keys || [field.key];
// field.show = show;
// field.shown = function() {
// return field.show || _.some(field.keys, function(key) { return !!tags[key]; });
// };
// field.modified = function() {
// var original = context.graph().base().entities[entity.id];
// return _.some(field.keys, function(key) {
// return original ? tags[key] !== original.tags[key] : tags[key];
// });
// };
// field.revert = function() {
// var original = context.graph().base().entities[entity.id],
// t = {};
// field.keys.forEach(function(key) {
// t[key] = original ? original.tags[key] : undefined;
// });
// return t;
// };
// field.present = function() {
// return _.some(field.keys, function(key) {
// return tags[key];
// });
// };
// field.remove = function() {
// var t = {};
// field.keys.forEach(function(key) {
// t[key] = undefined;
// });
// return t;
// };
// return field;
// }
function presets(selection) {
function presetEditor(selection) {
selection.call(uiDisclosure()
.title(t('inspector.all_fields'))
.expanded(expandedPreference)
@@ -305,38 +251,38 @@ export function uiPreset(context) {
}
presets.preset = function(_) {
presetEditor.preset = function(_) {
if (!arguments.length) return preset;
if (preset && preset.id === _.id) return presets;
if (preset && preset.id === _.id) return presetEditor;
preset = _;
fieldsArr = null;
return presets;
return presetEditor;
};
presets.state = function(_) {
presetEditor.state = function(_) {
if (!arguments.length) return state;
state = _;
return presets;
return presetEditor;
};
presets.tags = function(_) {
presetEditor.tags = function(_) {
if (!arguments.length) return tags;
tags = _;
// Don't reset fieldsArr here.
return presets;
return presetEditor;
};
presets.entityID = function(_) {
presetEditor.entityID = function(_) {
if (!arguments.length) return id;
if (id === _) return presets;
if (id === _) return presetEditor;
id = _;
fieldsArr = null;
return presets;
return presetEditor;
};
return utilRebind(presets, dispatch, 'on');
return utilRebind(presetEditor, dispatch, 'on');
}