Skip to content

Commit

Permalink
[explore] fix empty chart when changing viz type
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 29, 2017
1 parent dee3649 commit 188f883
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ChartContainer extends React.PureComponent {
) && !this.props.queryResponse.error
&& this.props.chartStatus !== 'failed'
&& this.props.chartStatus !== 'stopped'
&& this.props.chartStatus !== 'loading'
) {
this.renderViz();
}
Expand Down
17 changes: 13 additions & 4 deletions superset/assets/javascripts/explorev2/components/Control.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,26 @@ export default class Control extends React.PureComponent {
super(props);
this.validate = this.validate.bind(this);
this.onChange = this.onChange.bind(this);
this.validateAndSetValue(props.value, []);
}
componentDidMount() {
this.validateAndSetValue(this.props.value, []);
}
onChange(value, errors) {
this.validateAndSetValue(value, errors);
}
validateAndSetValue(value, errors) {
let validationErrors = this.validate(value);
let validationErrors = this.props.validationErrors;
let currentErrors = this.validate(value);
if (errors && errors.length > 0) {
validationErrors = validationErrors.concat(errors);
currentErrors = validationErrors.concat(errors);
}
if (validationErrors.length + currentErrors.length > 0) {
validationErrors = currentErrors;
}

if (value !== this.props.value || validationErrors != this.props.validationErrors) {
this.props.actions.setControlValue(this.props.name, value, validationErrors);
}
this.props.actions.setControlValue(this.props.name, value, validationErrors);
}
validate(value) {
const validators = this.props.validators;
Expand Down
1 change: 1 addition & 0 deletions superset/assets/javascripts/explorev2/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const bootstrappedState = Object.assign(
queryResponse: null,
triggerQuery: true,
triggerRender: false,
alert: null,
},
);

Expand Down
1 change: 1 addition & 0 deletions superset/assets/javascripts/explorev2/stores/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function getControlsState(state, form_data) {
if (typeof control.default === 'function') {
control.default = control.default(control);
}
control.validationErrors = [];
control.value = formData[k] !== undefined ? formData[k] : control.default;
controlsState[k] = control;
});
Expand Down

0 comments on commit 188f883

Please sign in to comment.