Skip to content

Commit

Permalink
[Table Viz] columns not match with group_by control (#5329)
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace Guo authored Jul 16, 2018
1 parent 709f056 commit 0d10cc5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion superset/assets/src/explore/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = []
Expand Down

0 comments on commit 0d10cc5

Please sign in to comment.