Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[explore] using verbose_name in 'Time Column' control #3529

Merged
merged 1 commit into from Nov 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 18 additions & 7 deletions superset/assets/javascripts/explore/stores/controls.jsx
Expand Up @@ -568,17 +568,28 @@ export const controls = {
granularity_sqla: {
type: 'SelectControl',
label: t('Time Column'),
default: control =>
control.choices && control.choices.length > 0 ? control.choices[0][0] : null,
description: t('The time column for the visualization. Note that you ' +
'can define arbitrary expression that return a DATETIME ' +
'column in the table or. Also note that the ' +
'column in the table. Also note that the ' +
'filter below is applied against this column or ' +
'expression'),
mapStateToProps: state => ({
choices: (state.datasource) ? state.datasource.granularity_sqla : [],
}),
freeForm: true,
default: (c) => {
if (c.options && c.options.length > 0) {
return c.options[0].column_name;
}
return null;
},
clearable: false,
optionRenderer: c => <ColumnOption column={c} />,
valueRenderer: c => <ColumnOption column={c} />,
valueKey: 'column_name',
mapStateToProps: (state) => {
const newState = {};
if (state.datasource) {
newState.options = state.datasource.columns.filter(c => c.is_dttm);
}
return newState;
},
},

time_grain_sqla: {
Expand Down
3 changes: 2 additions & 1 deletion superset/connectors/base/models.py
Expand Up @@ -209,6 +209,7 @@ class BaseColumn(AuditMixinNullable, ImportMixin):
min = Column(Boolean, default=False)
filterable = Column(Boolean, default=False)
description = Column(Text)
is_dttm = None

# [optional] Set this to support import/export functionality
export_fields = []
Expand Down Expand Up @@ -252,7 +253,7 @@ def expression(self):
def data(self):
attrs = (
'column_name', 'verbose_name', 'description', 'expression',
'filterable', 'groupby')
'filterable', 'groupby', 'is_dttm')
return {s: getattr(self, s) for s in attrs}


Expand Down