You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by gr...@apache.org on 2017/11/06 23:21:36 UTC
[incubator-superset] branch master updated: [explore] using
verbose_name in 'Time Column' control (#3529)
This is an automated email from the ASF dual-hosted git repository.
graceguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 81dd622 [explore] using verbose_name in 'Time Column' control (#3529)
81dd622 is described below
commit 81dd622fdb2a6139d2ad60931bf14b83ba65470a
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Mon Nov 6 15:21:34 2017 -0800
[explore] using verbose_name in 'Time Column' control (#3529)
---
.../assets/javascripts/explore/stores/controls.jsx | 25 ++++++++++++++++------
superset/connectors/base/models.py | 3 ++-
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/superset/assets/javascripts/explore/stores/controls.jsx b/superset/assets/javascripts/explore/stores/controls.jsx
index fa92cd5..e3da06b 100644
--- a/superset/assets/javascripts/explore/stores/controls.jsx
+++ b/superset/assets/javascripts/explore/stores/controls.jsx
@@ -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: {
diff --git a/superset/connectors/base/models.py b/superset/connectors/base/models.py
index bf66c60..4f3dab0 100644
--- a/superset/connectors/base/models.py
+++ b/superset/connectors/base/models.py
@@ -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 = []
@@ -252,7 +253,7 @@ class BaseColumn(AuditMixinNullable, ImportMixin):
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}
--
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <co...@superset.apache.org>'].