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
- {state.renderAsTabs && + {props.value && } @@ -114,7 +111,7 @@ export default new Map([ component: DataInputPeriods, }], ['renderAsTabs', { - component: RenderAsTabsSettings, + component: addD2Context(RenderAsTabsSettings), }] ]); diff --git a/src/i18n/i18n_module_en.properties b/src/i18n/i18n_module_en.properties index 18c3d86c8..3647b4efc 100644 --- a/src/i18n/i18n_module_en.properties +++ b/src/i18n/i18n_module_en.properties @@ -623,6 +623,8 @@ no_value_requires_comment=Missing value requires comment on complete skip_offline=Skip offline render_options_as_radio=Render options as radio render_as_tabs=Render sections as tabs +horizontal=Horizontal +vertical=Vertical render_horizontally=Render vertically compulsory_fields_complete_only=Complete allowed only if compulsory fields are filled auto_save_data_entry_forms=Auto-save data entry forms