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 2018/07/16 21:06:32 UTC
[incubator-superset] branch master updated: [Table Viz] columns not
match with group_by control (#5329)
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 0d10cc5 [Table Viz] columns not match with group_by control (#5329)
0d10cc5 is described below
commit 0d10cc569d7157815098fde64a69b72da0d54818
Author: Grace Guo <gr...@airbnb.com>
AuthorDate: Mon Jul 16 14:06:29 2018 -0700
[Table Viz] columns not match with group_by control (#5329)
---
.../assets/src/explore/components/controls/MetricsControl.jsx | 6 ++++++
superset/assets/src/explore/store.js | 8 +++++++-
superset/viz.py | 2 +-
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/superset/assets/src/explore/components/controls/MetricsControl.jsx b/superset/assets/src/explore/components/controls/MetricsControl.jsx
index e93f6c1..0b2d14c 100644
--- a/superset/assets/src/explore/components/controls/MetricsControl.jsx
+++ b/superset/assets/src/explore/components/controls/MetricsControl.jsx
@@ -139,6 +139,12 @@ export default class MetricsControl extends React.PureComponent {
}
onChange(opts) {
+ // if clear out options
+ if (opts === null) {
+ this.props.onChange(null);
+ return;
+ }
+
let transformedOpts = opts;
if (!this.props.multi) {
transformedOpts = [opts].filter(option => option);
diff --git a/superset/assets/src/explore/store.js b/superset/assets/src/explore/store.js
index 48a24df..0f345ac 100644
--- a/superset/assets/src/explore/store.js
+++ b/superset/assets/src/explore/store.js
@@ -73,7 +73,13 @@ export function getControlsState(state, form_data) {
control.default = control.default(control);
}
control.validationErrors = [];
- control.value = formData[k] !== undefined ? formData[k] : control.default;
+ control.value = control.default;
+ // formData[k]'s type should match control value type
+ if (formData[k] !== undefined &&
+ (Array.isArray(formData[k]) && control.multi || !control.multi)
+ ) {
+ control.value = formData[k];
+ }
controlsState[k] = control;
});
if (viz.onInit) {
diff --git a/superset/viz.py b/superset/viz.py
index 13f139d..73a5d4e 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -509,7 +509,7 @@ class TableViz(BaseViz):
'Choose either fields to [Group By] and [Metrics] or '
'[Columns], not both'))
- sort_by = fd.get('timeseries_limit_metric') or []
+ sort_by = fd.get('timeseries_limit_metric')
if fd.get('all_columns'):
d['columns'] = fd.get('all_columns')
d['groupby'] = []