mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix: missing groupby/dimension select options (#21)
This commit is contained in:
parent
e0c28e38f5
commit
667d56c0d1
@ -21,16 +21,9 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { t, validateNonEmpty } from '@superset-ui/core';
|
import { t, validateNonEmpty } from '@superset-ui/core';
|
||||||
import { ColumnOption } from '@superset-ui/chart-controls';
|
import { sharedControls } from '@superset-ui/chart-controls';
|
||||||
import { D3_FORMAT_OPTIONS, columnChoices, PRIMARY_COLOR } from './controls';
|
import { D3_FORMAT_OPTIONS, columnChoices, PRIMARY_COLOR } from './controls';
|
||||||
|
|
||||||
const timeColumnOption = {
|
|
||||||
verbose_name: 'Time',
|
|
||||||
column_name: '__timestamp',
|
|
||||||
// eslint-disable-next-line no-useless-concat
|
|
||||||
description: t('A reference to the [Time] configuration, taking granularity into ' + 'account'),
|
|
||||||
};
|
|
||||||
|
|
||||||
const DEFAULT_VIEWPORT = {
|
const DEFAULT_VIEWPORT = {
|
||||||
longitude: 6.85236157047845,
|
longitude: 6.85236157047845,
|
||||||
latitude: 31.222656842808707,
|
latitude: 31.222656842808707,
|
||||||
@ -39,35 +32,6 @@ const DEFAULT_VIEWPORT = {
|
|||||||
pitch: 0,
|
pitch: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const groupByControl = {
|
|
||||||
type: 'SelectControl',
|
|
||||||
multi: true,
|
|
||||||
freeForm: true,
|
|
||||||
label: t('Group by'),
|
|
||||||
default: [],
|
|
||||||
includeTime: false,
|
|
||||||
description: t('One or many controls to group by'),
|
|
||||||
optionRenderer: c => <ColumnOption showType column={c} />,
|
|
||||||
valueRenderer: c => <ColumnOption column={c} />,
|
|
||||||
valueKey: 'column_name',
|
|
||||||
allowAll: true,
|
|
||||||
filterOption: (opt, text) =>
|
|
||||||
(opt.column_name && opt.column_name.toLowerCase().includes(text.toLowerCase())) ||
|
|
||||||
(opt.verbose_name && opt.verbose_name.toLowerCase().includes(text.toLowerCase())),
|
|
||||||
promptTextCreator: label => label,
|
|
||||||
mapStateToProps: (state, control) => {
|
|
||||||
const newState = {};
|
|
||||||
if (state.datasource) {
|
|
||||||
newState.options = state.datasource.columns.filter(c => c.groupby);
|
|
||||||
if (control && control.includeTime) {
|
|
||||||
newState.options.push(timeColumnOption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newState;
|
|
||||||
},
|
|
||||||
commaChoosesOption: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
const sandboxUrl =
|
const sandboxUrl =
|
||||||
'https://github.com/apache/incubator-superset/' +
|
'https://github.com/apache/incubator-superset/' +
|
||||||
'blob/master/superset-frontend/src/modules/sandbox.js';
|
'blob/master/superset-frontend/src/modules/sandbox.js';
|
||||||
@ -129,7 +93,7 @@ export const autozoom = {
|
|||||||
export const dimension = {
|
export const dimension = {
|
||||||
name: 'dimension',
|
name: 'dimension',
|
||||||
config: {
|
config: {
|
||||||
...groupByControl,
|
...sharedControls.groupby,
|
||||||
label: t('Dimension'),
|
label: t('Dimension'),
|
||||||
description: t('Select a dimension'),
|
description: t('Select a dimension'),
|
||||||
multi: false,
|
multi: false,
|
||||||
@ -140,7 +104,7 @@ export const dimension = {
|
|||||||
export const jsColumns = {
|
export const jsColumns = {
|
||||||
name: 'js_columns',
|
name: 'js_columns',
|
||||||
config: {
|
config: {
|
||||||
...groupByControl,
|
...sharedControls.groupby,
|
||||||
label: t('Extra data for JS'),
|
label: t('Extra data for JS'),
|
||||||
default: [],
|
default: [],
|
||||||
description: t('List of extra columns made available in Javascript functions'),
|
description: t('List of extra columns made available in Javascript functions'),
|
||||||
|
Loading…
Reference in New Issue
Block a user