Fixes inputs

This commit is contained in:
Roman Galochkin 2020-03-03 14:51:35 +03:00
parent f1f75df73b
commit dcea2c70af

View File

@ -45,18 +45,20 @@ module FieldString = {
module FieldNumber = { module FieldNumber = {
[@react.component] [@react.component]
let make = (~field, ~label) => { let make = (~field, ~label, ~min=0) => {
<Form.Field <Form.Field
field field
render={({handleChange, error, value, validate}) => render={({handleChange, error, value, validate}) =>
<Antd.Form.Item label={label |> E.ste}> <Antd.Form.Item label={label |> E.ste}>
<Antd.InputNumber <Antd.InputNumber
value value
onChange={e => { onChange=handleChange
e |> handleChange; min
();
}}
onBlur={_ => validate()} onBlur={_ => validate()}
parser={str => {
let a = str |> Js.Float.fromString |> int_of_float;
a < min ? min : a;
}}
/> />
</Antd.Form.Item> </Antd.Form.Item>
} }
@ -66,19 +68,22 @@ module FieldNumber = {
module FieldFloat = { module FieldFloat = {
[@react.component] [@react.component]
let make = (~field, ~label, ~className=Css.style([])) => { let make =
(~field, ~label, ~className=Css.style([]), ~min=0., ~precision=2) => {
<Form.Field <Form.Field
field field
render={({handleChange, error, value, validate}) => render={({handleChange, error, value, validate}) =>
<Antd.Form.Item label={label |> E.ste}> <Antd.Form.Item label={label |> E.ste}>
<Antd.InputFloat <Antd.InputFloat
value value
onChange={e => { precision
e |> handleChange; onChange=handleChange
();
}}
onBlur={_ => validate()} onBlur={_ => validate()}
className className
parser={str => {
let a = str |> Js.Float.fromString;
Js.Float.isNaN(a) ? min : a;
}}
/> />
</Antd.Form.Item> </Antd.Form.Item>
} }
@ -440,16 +445,25 @@ let make = () => {
</Row> </Row>
<Row _type=`flex className=Styles.rows> <Row _type=`flex className=Styles.rows>
<Col span=4> <Col span=4>
<FieldNumber field=FormConfig.SampleCount label="Sample Count" /> <FieldNumber
field=FormConfig.SampleCount
label="Sample Count"
min=100
/>
</Col> </Col>
<Col span=4> <Col span=4>
<FieldNumber <FieldNumber
field=FormConfig.OutputXYPoints field=FormConfig.OutputXYPoints
label="Output XY-points" label="Output XY-points"
min=100
/> />
</Col> </Col>
<Col span=4> <Col span=4>
<FieldNumber field=FormConfig.TruncateTo label="Truncate To" /> <FieldNumber
field=FormConfig.TruncateTo
label="Truncate To"
min=10
/>
</Col> </Col>
</Row> </Row>
<Antd.Button <Antd.Button