77 SelectElement ,
88 NumericElement ,
99} from 'jsx/Form' ;
10+ import { withTranslation } from 'react-i18next' ;
1011
1112/**
1213 * Battery Manager Form
@@ -22,26 +23,42 @@ class BatteryManagerForm extends Component {
2223 * @return {* }
2324 */
2425 render ( ) {
25- const { test, options, setTest, add, errors, handleSubmit} = this . props ;
26+ const { test, options, setTest, add, errors, handleSubmit, t } = this . props ;
2627
28+ // Inform users about duplicate entries
2729 const renderHelpText = ( ) => {
2830 if ( add ) {
2931 return (
3032 < span >
31- You cannot add an entry if it has a duplicate entry in the test
32- battery.< br />
33- If the duplicate entry is inactive, you will be given the option
34- to activate it.
33+ { t (
34+ 'You cannot add an entry if it has a duplicate entry in the ' +
35+ 'test battery.' ,
36+ { ns : 'battery_manager' }
37+ ) } < br />
38+ { t (
39+ 'If the duplicate entry is inactive, you will be given the ' +
40+ 'option to activate it.' ,
41+ { ns : 'battery_manager' }
42+ ) }
3543 </ span >
3644 ) ;
3745 } else {
3846 return (
3947 < span >
40- Editing an entry will alter the current entry.< br />
41- You cannot edit an entry to have the same values as another active
42- entry.< br />
43- If the duplicate entry is inactive, you will be given the option
44- to activate it.
48+ { t (
49+ 'Editing an entry will alter the current entry.' ,
50+ { ns : 'battery_manager' }
51+ ) } < br />
52+ { t (
53+ 'You cannot edit an entry to have the same values as another ' +
54+ 'active entry.' ,
55+ { ns : 'battery_manager' }
56+ ) } < br />
57+ { t (
58+ 'If the duplicate entry is inactive, you will be given the ' +
59+ 'option to activate it.' ,
60+ { ns : 'battery_manager' }
61+ ) }
4562 < br />
4663 < br />
4764 </ span >
@@ -55,22 +72,22 @@ class BatteryManagerForm extends Component {
5572 onSubmit = { handleSubmit }
5673 >
5774 < StaticElement
58- label = " Note"
75+ label = { t ( ' Note' , { ns : 'loris' } ) }
5976 text = { renderHelpText ( ) }
6077 />
6178 < SelectElement
6279 name = "testName"
63- label = " Instrument"
64- placeHolder = " Search for instrument"
80+ label = { t ( ' Instrument' , { ns : 'battery_manager' } ) }
81+ placeHolder = { t ( ' Search for instrument' , { ns : 'battery_manager' } ) }
6582 options = { options . instruments }
6683 onUserInput = { setTest }
6784 required = { true }
68- value = { test . testName ?? '' }
85+ value = { test . testName }
6986 errorMessage = { errors . testName }
7087 />
7188 < NumericElement
7289 name = "ageMinDays"
73- label = " Minimum age (days)"
90+ label = { t ( ' Minimum Age (days)' , { ns : 'battery_manager' } ) }
7491 onUserInput = { setTest }
7592 min = { 0 }
7693 max = { 99999 }
@@ -80,7 +97,7 @@ class BatteryManagerForm extends Component {
8097 />
8198 < NumericElement
8299 name = "ageMaxDays"
83- label = " Maximum age (days)"
100+ label = { t ( ' Maximum Age (days)' , { ns : 'battery_manager' } ) }
84101 onUserInput = { setTest }
85102 min = { 0 }
86103 max = { 99999 }
@@ -90,68 +107,74 @@ class BatteryManagerForm extends Component {
90107 />
91108 < SelectElement
92109 name = "stage"
93- label = " Stage"
110+ label = { t ( ' Stage' , { ns : 'battery_manager' } ) }
94111 options = { options . stages }
95112 onUserInput = { setTest }
96113 required = { true }
97- value = { test . stage ?? '' }
114+ value = { test . stage }
98115 errorMessage = { errors . stage }
99116 />
100117 < SelectElement
101118 name = "cohort"
102- label = " Cohort"
119+ label = { t ( ' Cohort' , { ns : 'loris' , count : 1 } ) }
103120 options = { options . cohorts }
104121 onUserInput = { setTest }
105122 required = { false }
106- value = { test . cohort ?? '' }
123+ value = { test . cohort }
107124 />
108125 < SelectElement
109126 name = "visitLabel"
110- label = " Visit Label"
127+ label = { t ( ' Visit Label' , { ns : 'loris' } ) }
111128 options = { options . visits }
112129 onUserInput = { setTest }
113130 required = { false }
114- value = { test . visitLabel ?? '' }
131+ value = { test . visitLabel }
115132 />
116133 < SelectElement
117134 name = "centerId"
118- label = " Site"
119- placeHolder = " Search for site"
135+ label = { t ( ' Site' , { ns : 'loris' , count : 1 } ) }
136+ placeHolder = { t ( ' Search for site' , { ns : 'battery_manager' } ) }
120137 options = { options . sites }
121138 strictSearch = { true }
122139 onUserInput = { setTest }
123140 required = { false }
124- value = { test . centerId ?? '' }
141+ value = { test . centerId }
125142 />
126143 < SelectElement
127144 name = "firstVisit"
128- label = "First Visit"
129- options = { options . firstVisit }
145+ label = { t ( 'First Visit' , { ns : 'battery_manager' } ) }
146+ options = { {
147+ 'Y' : t ( 'Yes' , { ns : 'loris' } ) ,
148+ 'N' : t ( 'No' , { ns : 'loris' } ) ,
149+ } }
130150 onUserInput = { setTest }
131151 required = { false }
132- value = { test . firstVisit ?? '' }
152+ value = { test . firstVisit }
133153 />
134154 < NumericElement
135155 name = "instrumentOrder"
136- label = " Instrument Order"
156+ label = { t ( ' Instrument Order' , { ns : 'battery_manager' } ) }
137157 onUserInput = { setTest }
138158 required = { false }
139159 min = { 0 }
140- max = { 127 }
141- value = { test . instrumentOrder != null ?
142- String ( test . instrumentOrder ) : '' }
160+ max = { 127 } // max value allowed by default column type of instr_order
161+ value = { test . instrumentOrder }
143162 />
144163 < SelectElement
145164 name = "DoubleDataEntryEnabled"
146- label = "Enable Double Data Entry"
147- options = { options . DoubleDataEntryEnabled }
165+ label = { t ( 'Enable Double Data Entry' , { ns : 'battery_manager' } ) }
166+ options = { {
167+ 'Y' : t ( 'Yes' , { ns : 'loris' } ) ,
168+ 'N' : t ( 'No' , { ns : 'loris' } ) ,
169+ } }
148170 onUserInput = { setTest }
149171 required = { true }
150- value = { test . DoubleDataEntryEnabled ?? '' }
172+ value = { test . DoubleDataEntryEnabled }
173+ errorMessage = { errors . DoubleDataEntryEnabled }
151174 emptyOption = { false }
152175 />
153176 < ButtonElement
154- label = " Submit"
177+ label = { t ( ' Submit' , { ns : 'battery_manager' } ) }
155178 />
156179 </ FormElement >
157180 ) ;
@@ -165,7 +188,8 @@ BatteryManagerForm.propTypes = {
165188 add : PropTypes . bool ,
166189 errors : PropTypes . object ,
167190 handleSubmit : PropTypes . func . isRequired ,
191+ t : PropTypes . func ,
168192} ;
169193
170- export default BatteryManagerForm ;
171-
194+ export default withTranslation (
195+ [ 'battery_manager' , 'loris' ] ) ( BatteryManagerForm ) ;
0 commit comments