diff --git a/src/config/field-overrides/dataSet.js b/src/config/field-overrides/dataSet.js index 0a091e77e..b43624c25 100644 --- a/src/config/field-overrides/dataSet.js +++ b/src/config/field-overrides/dataSet.js @@ -5,15 +5,18 @@ import DataInputPeriods from './data-set/DataInputPeriods.component'; import PeriodTypeDropDown from '../../forms/form-fields/period-type-drop-down'; import Checkbox from '../../forms/form-fields/check-box'; import {RadioButton, RadioButtonGroup} from "material-ui/RadioButton"; +import addD2Context from 'd2-ui/lib/component-helpers/addD2Context'; import log from "loglevel"; class RenderAsTabsSettings extends React.Component { - constructor(props) { + constructor(props, context) { super(props); this.state = { - renderAsTabs: props.value, displayOptions: this.parseDisplayOptions() }; + this.translate = context.d2.i18n.getTranslation.bind( + context.d2.i18n + ); } parseDisplayOptions = () => { @@ -32,10 +35,7 @@ class RenderAsTabsSettings extends React.Component { ...this.state.displayOptions, tabsDirection } - this.setState((prevState, _) => ({ - ...prevState, - displayOptions: newDisplayOptions - })); + this.setState({displayOptions: newDisplayOptions}); this.props.model.displayOptions = JSON.stringify(newDisplayOptions) } @@ -44,17 +44,13 @@ class RenderAsTabsSettings extends React.Component { this.updateTabsDirection(tabsDirection) } - onDisplayAsTabsChanged = (event) => { + onRenderAsTabsChanged = (event) => { const renderAsTabs = event.target.value const tabsDirection = renderAsTabs ? 'horizontal' : undefined - this.setState((prevState) => ({ - ...prevState, - renderAsTabs - })); this.props.onChange({ target: { value: renderAsTabs } }); this.updateTabsDirection(tabsDirection) } @@ -62,13 +58,14 @@ class RenderAsTabsSettings extends React.Component { render() { const state = this.state; + const props = this.props; return