You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/07/16 21:06:31 UTC

[GitHub] graceguo-supercat closed pull request #5329: [Table Viz] Table columns not match with group_by control

graceguo-supercat closed pull request #5329: [Table Viz] Table columns not match with group_by control
URL: https://github.com/apache/incubator-superset/pull/5329
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/src/explore/components/controls/MetricsControl.jsx b/superset/assets/src/explore/components/controls/MetricsControl.jsx
index e93f6c1879..0b2d14ca93 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 48a24df511..0f345ac6eb 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 e36df190c1..0d177e67f1 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -509,7 +509,7 @@ def query_obj(self):
                 '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'] = []


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org