Simplifying the Fields (Controls) interface (#1868)

* Simplifying the Field interface / logic

* Moving ControlLabelWithTooltip where it belongs

* Progress

* Rename FieldClass->FieldType
This commit is contained in:
Maxime Beauchemin
2017-01-04 15:46:52 -08:00
committed by GitHub
parent 861a3bd4ae
commit 7aab8b0ae3
7 changed files with 111 additions and 119 deletions

View File

@@ -1,16 +1,6 @@
import { formatSelectOptionsForRange, formatSelectOptions } from '../../modules/utils';
import visTypes from './visTypes';
export const fieldTypes = [
'CheckboxField',
'FreeFormSelectField',
'IntegerField',
'SelectCustomMultiField',
'SelectField',
'SelectMultipleSortableField',
'TextAreaFeild',
'TextField',
];
const D3_FORMAT_DOCS = 'D3 format syntax: https://github.com/d3/d3-format';
// input choices & options
@@ -55,7 +45,9 @@ export const fields = {
},
metrics: {
type: 'SelectMultipleSortableField',
type: 'SelectField',
multi: true,
freeForm: false,
label: 'Metrics',
choices: [],
default: [],
@@ -63,7 +55,9 @@ export const fields = {
},
order_by_cols: {
type: 'SelectMultipleSortableField',
type: 'SelectField',
multi: true,
freeForm: false,
label: 'Ordering',
choices: [],
default: [],
@@ -237,7 +231,9 @@ export const fields = {
},
groupby: {
type: 'SelectMultipleSortableField',
type: 'SelectField',
multi: true,
freeForm: false,
label: 'Group by',
choices: [],
default: [],
@@ -245,7 +241,9 @@ export const fields = {
},
columns: {
type: 'SelectMultipleSortableField',
type: 'SelectField',
multi: true,
freeForm: false,
label: 'Columns',
choices: [],
default: [],
@@ -253,7 +251,9 @@ export const fields = {
},
all_columns: {
type: 'SelectMultipleSortableField',
type: 'SelectField',
multi: true,
freeForm: false,
label: 'Columns',
choices: [],
default: [],
@@ -277,7 +277,9 @@ export const fields = {
},
druid_time_origin: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Origin',
choices: [
['', 'default'],
@@ -289,7 +291,9 @@ export const fields = {
},
bottom_margin: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Bottom Margin',
choices: formatSelectOptions(['auto', 50, 75, 100, 125, 150, 200]),
default: 'auto',
@@ -297,7 +301,9 @@ export const fields = {
},
granularity: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Time Granularity',
default: 'one day',
choices: formatSelectOptions([
@@ -338,7 +344,9 @@ export const fields = {
},
link_length: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Link Length',
default: '200',
choices: formatSelectOptions(['10', '25', '50', '75', '100', '150', '200', '250']),
@@ -346,7 +354,9 @@ export const fields = {
},
charge: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Charge',
default: '-500',
choices: formatSelectOptions([
@@ -389,7 +399,9 @@ export const fields = {
},
resample_rule: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Resample Rule',
default: null,
choices: formatSelectOptions(['', '1T', '1H', '1D', '7D', '1M', '1AS']),
@@ -397,7 +409,9 @@ export const fields = {
},
resample_how: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Resample How',
default: null,
choices: formatSelectOptions(['', 'mean', 'sum', 'median']),
@@ -405,7 +419,9 @@ export const fields = {
},
resample_fillmethod: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Resample Fill Method',
default: null,
choices: formatSelectOptions(['', 'ffill', 'bfill']),
@@ -413,7 +429,9 @@ export const fields = {
},
since: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Since',
default: '7 days ago',
choices: formatSelectOptions([
@@ -431,7 +449,9 @@ export const fields = {
},
until: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Until',
default: 'now',
choices: formatSelectOptions([
@@ -445,14 +465,18 @@ export const fields = {
},
max_bubble_size: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Max Bubble Size',
default: '25',
choices: formatSelectOptions(['5', '10', '15', '25', '50', '75', '100']),
},
whisker_options: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Whisker/outlier options',
default: 'Tukey',
description: 'Determines how whiskers and outliers are calculated.',
@@ -472,7 +496,9 @@ export const fields = {
},
number_format: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Number format',
default: D3_TIME_FORMAT_OPTIONS[0],
choices: D3_TIME_FORMAT_OPTIONS,
@@ -480,14 +506,18 @@ export const fields = {
},
row_limit: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Row limit',
default: null,
choices: formatSelectOptions(ROW_LIMIT_OPTIONS),
},
limit: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Series limit',
choices: formatSelectOptions(SERIES_LIMITS),
default: 50,
@@ -613,7 +643,9 @@ export const fields = {
},
table_timestamp_format: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Table Timestamp Format',
default: 'smart_date',
choices: TIME_STAMP_OPTIONS,
@@ -621,7 +653,9 @@ export const fields = {
},
series_height: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Series Height',
default: '25',
choices: formatSelectOptions(['10', '25', '40', '50', '75', '100', '150', '200']),
@@ -629,7 +663,9 @@ export const fields = {
},
page_length: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Page Length',
default: 0,
choices: formatSelectOptions([0, 10, 25, 40, 50, 75, 100, 150, 200]),
@@ -637,7 +673,9 @@ export const fields = {
},
x_axis_format: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'X axis format',
default: 'smart_date',
choices: TIME_STAMP_OPTIONS,
@@ -645,7 +683,9 @@ export const fields = {
},
y_axis_format: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Y axis format',
default: '.3s',
choices: D3_TIME_FORMAT_OPTIONS,
@@ -868,7 +908,9 @@ export const fields = {
},
mapbox_label: {
type: 'SelectMultipleSortableField',
type: 'SelectField',
multi: true,
freeForm: false,
label: 'label',
choices: [],
default: [],
@@ -894,7 +936,9 @@ export const fields = {
},
clustering_radius: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'Clustering Radius',
default: '60',
choices: formatSelectOptions([
@@ -972,7 +1016,9 @@ export const fields = {
},
mapbox_color: {
type: 'FreeFormSelectField',
type: 'SelectField',
multi: false,
freeForm: true,
label: 'RGB Color',
default: 'rgb(0, 122, 135)',
choices: [