From 955a4d1315debffea10a2c7a364aca21528ebcf6 Mon Sep 17 00:00:00 2001 From: khtruong Date: Mon, 15 Apr 2019 11:30:34 -0700 Subject: [PATCH 1/4] fix: time series table --- .../controls/TimeSeriesColumnControl.jsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx b/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx index 24ec40102d3d9..6f29917466f08 100644 --- a/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx +++ b/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx @@ -28,6 +28,7 @@ import BoundsControl from './BoundsControl'; import CheckboxControl from './CheckboxControl'; const propTypes = { + label: PropTypes.string, onChange: PropTypes.func, }; @@ -52,7 +53,21 @@ const colTypeOptions = [ export default class TimeSeriesColumnControl extends React.Component { constructor(props) { super(props); - const state = { ...props }; + const state = { + label: this.props.label, + tooltip: '', + colType: '', + width: '', + height: '', + timeLag: '', + timeRatio: '', + comparisonType: '', + showYAxis: false, + yAxisBounds: [null, null], + bounds: [null, null], + d3format: '', + dateFormat: '', + }; delete state.onChange; this.state = state; this.onChange = this.onChange.bind(this); From 4cbfc9b30af00e70d6ee187d5a920716d783cbae Mon Sep 17 00:00:00 2001 From: khtruong Date: Mon, 15 Apr 2019 13:02:04 -0700 Subject: [PATCH 2/4] fix: add default value for label --- .../src/explore/components/controls/TimeSeriesColumnControl.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx b/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx index 6f29917466f08..7adc706e7f829 100644 --- a/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx +++ b/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx @@ -22,6 +22,7 @@ import { Row, Col, FormControl, OverlayTrigger, Popover, } from 'react-bootstrap'; import Select from 'react-select'; +import { t } from '@superset-ui/translation'; import InfoTooltipWithTrigger from '../../../components/InfoTooltipWithTrigger'; import BoundsControl from './BoundsControl'; @@ -33,6 +34,7 @@ const propTypes = { }; const defaultProps = { + label: t('Time Series Columns'), onChange: () => {}, }; From 67136cdbbc732405e904494e828796e33ffc5c11 Mon Sep 17 00:00:00 2001 From: khtruong Date: Mon, 15 Apr 2019 15:31:52 -0700 Subject: [PATCH 3/4] fix: use prop values if defined --- .../components/controls/CollectionControl.jsx | 4 +-- .../controls/TimeSeriesColumnControl.jsx | 26 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/superset/assets/src/explore/components/controls/CollectionControl.jsx b/superset/assets/src/explore/components/controls/CollectionControl.jsx index 35390e97f83b9..31e37e80a72d3 100644 --- a/superset/assets/src/explore/components/controls/CollectionControl.jsx +++ b/superset/assets/src/explore/components/controls/CollectionControl.jsx @@ -101,8 +101,8 @@ export default class CollectionControl extends React.Component {
diff --git a/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx b/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx index 7adc706e7f829..47f504f2b81a8 100644 --- a/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx +++ b/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx @@ -30,11 +30,13 @@ import CheckboxControl from './CheckboxControl'; const propTypes = { label: PropTypes.string, + value: PropTypes.object, onChange: PropTypes.func, }; const defaultProps = { label: t('Time Series Columns'), + value: {}, onChange: () => {}, }; @@ -57,18 +59,18 @@ export default class TimeSeriesColumnControl extends React.Component { super(props); const state = { label: this.props.label, - tooltip: '', - colType: '', - width: '', - height: '', - timeLag: '', - timeRatio: '', - comparisonType: '', - showYAxis: false, - yAxisBounds: [null, null], - bounds: [null, null], - d3format: '', - dateFormat: '', + tooltip: this.props.value.tooltip || '', + colType: this.props.value.colType || '', + width: this.props.value.width || '', + height: this.props.value.height || '', + timeLag: this.props.value.timeLag || '', + timeRatio: this.props.value.timeRatio || '', + comparisonType: this.props.value.comparisonType || '', + showYAxis: this.props.value.showYAxis || false, + yAxisBounds: this.props.value.yAxisBounds || [null, null], + bounds: this.props.value.bounds || [null, null], + d3format: this.props.value.d3format || '', + dateFormat: this.props.value.dateFormat || '', }; delete state.onChange; this.state = state; From 071b2421946fc09c506f6be67be42e35caa84d6b Mon Sep 17 00:00:00 2001 From: khtruong Date: Tue, 16 Apr 2019 09:38:59 -0700 Subject: [PATCH 4/4] fix: revert CollectionControl changes --- .../components/controls/CollectionControl.jsx | 4 +- .../controls/TimeSeriesColumnControl.jsx | 50 +++++++++++++------ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/superset/assets/src/explore/components/controls/CollectionControl.jsx b/superset/assets/src/explore/components/controls/CollectionControl.jsx index 31e37e80a72d3..35390e97f83b9 100644 --- a/superset/assets/src/explore/components/controls/CollectionControl.jsx +++ b/superset/assets/src/explore/components/controls/CollectionControl.jsx @@ -101,8 +101,8 @@ export default class CollectionControl extends React.Component {
diff --git a/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx b/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx index 47f504f2b81a8..145f80f75c6ed 100644 --- a/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx +++ b/superset/assets/src/explore/components/controls/TimeSeriesColumnControl.jsx @@ -30,13 +30,35 @@ import CheckboxControl from './CheckboxControl'; const propTypes = { label: PropTypes.string, - value: PropTypes.object, + tooltip: PropTypes.string, + colType: PropTypes.string, + width: PropTypes.string, + height: PropTypes.string, + timeLag: PropTypes.string, + timeRatio: PropTypes.string, + comparisonType: PropTypes.string, + showYAxis: PropTypes.bool, + yAxisBounds: PropTypes.array, + bounds: PropTypes.array, + d3format: PropTypes.string, + dateFormat: PropTypes.string, onChange: PropTypes.func, }; const defaultProps = { label: t('Time Series Columns'), - value: {}, + tooltip: '', + colType: '', + width: '', + height: '', + timeLag: '', + timeRatio: '', + comparisonType: '', + showYAxis: false, + yAxisBounds: [null, null], + bounds: [null, null], + d3format: '', + dateFormat: '', onChange: () => {}, }; @@ -59,18 +81,18 @@ export default class TimeSeriesColumnControl extends React.Component { super(props); const state = { label: this.props.label, - tooltip: this.props.value.tooltip || '', - colType: this.props.value.colType || '', - width: this.props.value.width || '', - height: this.props.value.height || '', - timeLag: this.props.value.timeLag || '', - timeRatio: this.props.value.timeRatio || '', - comparisonType: this.props.value.comparisonType || '', - showYAxis: this.props.value.showYAxis || false, - yAxisBounds: this.props.value.yAxisBounds || [null, null], - bounds: this.props.value.bounds || [null, null], - d3format: this.props.value.d3format || '', - dateFormat: this.props.value.dateFormat || '', + tooltip: this.props.tooltip, + colType: this.props.colType, + width: this.props.width, + height: this.props.height, + timeLag: this.props.timeLag, + timeRatio: this.props.timeRatio, + comparisonType: this.props.comparisonType, + showYAxis: this.props.showYAxis, + yAxisBounds: this.props.yAxisBounds, + bounds: this.props.bounds, + d3format: this.props.d3format, + dateFormat: this.props.dateFormat, }; delete state.onChange; this.state = state;