Adds a inputs
This commit is contained in:
parent
fee4f1f97c
commit
4daa45962d
12
src/App.re
12
src/App.re
|
@ -1,13 +1,13 @@
|
|||
type route =
|
||||
| Model(string)
|
||||
| FormBuilder
|
||||
| DistBuilder
|
||||
| Home
|
||||
| NotFound;
|
||||
|
||||
let routeToPath = route =>
|
||||
switch (route) {
|
||||
| Model(modelId) => "/m/" ++ modelId
|
||||
| FormBuilder => "/form-builder"
|
||||
| DistBuilder => "/dist-builder"
|
||||
| Home => "/"
|
||||
| _ => "/"
|
||||
};
|
||||
|
@ -73,8 +73,8 @@ module Menu = {
|
|||
</Item>
|
||||
})
|
||||
|> ReasonReact.array}
|
||||
<Item href={routeToPath(FormBuilder)} key="form-builder">
|
||||
{"Form Builder" |> E.ste}
|
||||
<Item href={routeToPath(DistBuilder)} key="dist-builder">
|
||||
{"Dist Builder" |> E.ste}
|
||||
</Item>
|
||||
</div>;
|
||||
};
|
||||
|
@ -87,7 +87,7 @@ let make = () => {
|
|||
let routing =
|
||||
switch (url.path) {
|
||||
| ["m", modelId] => Model(modelId)
|
||||
| ["form-builder"] => FormBuilder
|
||||
| ["dist-builder"] => DistBuilder
|
||||
| [] => Home
|
||||
| _ => NotFound
|
||||
};
|
||||
|
@ -100,7 +100,7 @@ let make = () => {
|
|||
| Some(model) => <FormBuilder.ModelForm model key=id />
|
||||
| None => <div> {"Page is not found" |> E.ste} </div>
|
||||
}
|
||||
| FormBuilder => <div> {"Form Builder" |> E.ste} </div>
|
||||
| DistBuilder => <DistBuilder />
|
||||
| Home => <div> {"Welcome" |> E.ste} </div>
|
||||
| _ => <div> {"Page is not found" |> E.ste} </div>
|
||||
}}
|
||||
|
|
|
@ -2,9 +2,15 @@ open BsReform;
|
|||
|
||||
module FormConfig = [%lenses
|
||||
type state = {
|
||||
name: string,
|
||||
description: string,
|
||||
picture: string,
|
||||
guesstimatorString: string,
|
||||
//
|
||||
domainType: string, // Complete, LeftLimited(...), RightLimited(...), LeftAndRightLimited(..., ...)
|
||||
xPoint: string,
|
||||
excludingProbabilityMass: string,
|
||||
//
|
||||
unitType: string, // UnspecifiedDistribution, TimeDistribution(zero, unit)
|
||||
zero: MomentRe.Moment.t,
|
||||
unit: string,
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -30,6 +36,24 @@ module FieldString = {
|
|||
};
|
||||
};
|
||||
|
||||
module FieldFloat = {
|
||||
[@react.component]
|
||||
let make = (~field, ~label) => {
|
||||
<Form.Field
|
||||
field
|
||||
render={({handleChange, error, value, validate}) =>
|
||||
<Antd.Form.Item label={label |> E.ste}>
|
||||
<Antd.Input
|
||||
value
|
||||
onChange={BsReform.Helpers.handleChange(handleChange)}
|
||||
onBlur={_ => validate()}
|
||||
/>
|
||||
</Antd.Form.Item>
|
||||
}
|
||||
/>;
|
||||
};
|
||||
};
|
||||
|
||||
[@react.component]
|
||||
let make = () => {
|
||||
let reform =
|
||||
|
@ -37,7 +61,15 @@ let make = () => {
|
|||
~validationStrategy=OnDemand,
|
||||
~schema,
|
||||
~onSubmit=({state}) => {None},
|
||||
~initialState={name: "", description: "", picture: ""},
|
||||
~initialState={
|
||||
guesstimatorString: "mm(5 to 20, floor(normal(20,2)), [.5, .5])",
|
||||
domainType: "Complete",
|
||||
xPoint: "0.0",
|
||||
excludingProbabilityMass: "",
|
||||
unitType: "UnspecifiedDistribution",
|
||||
zero: MomentRe.momentNow(),
|
||||
unit: "days",
|
||||
},
|
||||
(),
|
||||
);
|
||||
|
||||
|
@ -48,9 +80,102 @@ let make = () => {
|
|||
|
||||
<Form.Provider value=reform>
|
||||
<Antd.Form onSubmit>
|
||||
<FieldString field=FormConfig.Name label="Name" />
|
||||
<FieldString field=FormConfig.Description label="Description" />
|
||||
<FieldString field=FormConfig.Picture label="Picture" />
|
||||
<FieldString
|
||||
field=FormConfig.GuesstimatorString
|
||||
label="GuesstimatorString"
|
||||
/>
|
||||
<Form.Field
|
||||
field=FormConfig.DomainType
|
||||
render={({handleChange, value}) =>
|
||||
<Antd.Form.Item label={"Domain Type" |> E.ste}>
|
||||
<Antd.Select value onChange={e => e |> handleChange}>
|
||||
<Antd.Select.Option value="Complete">
|
||||
{"Complete" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="LeftLimited">
|
||||
{"LeftLimited" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="RightLimited">
|
||||
{"RightLimited" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="LeftAndRightLimited">
|
||||
{"LeftAndRightLimited" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
</Antd.Select>
|
||||
</Antd.Form.Item>
|
||||
}
|
||||
/>
|
||||
<FieldString field=FormConfig.XPoint label="xPoint" />
|
||||
<FieldString
|
||||
field=FormConfig.ExcludingProbabilityMass
|
||||
label="excludingProbabilityMass"
|
||||
/>
|
||||
<Form.Field
|
||||
field=FormConfig.UnitType
|
||||
render={({handleChange, value}) =>
|
||||
<Antd.Form.Item label={"Zero Type" |> E.ste}>
|
||||
<Antd.Select value onChange={e => e |> handleChange}>
|
||||
<Antd.Select.Option value="UnspecifiedDistribution">
|
||||
{"UnspecifiedDistribution" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="TimeDistribution">
|
||||
{"TimeDistribution" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
</Antd.Select>
|
||||
</Antd.Form.Item>
|
||||
}
|
||||
/>
|
||||
<Form.Field
|
||||
field=FormConfig.Zero
|
||||
render={({handleChange, value}) =>
|
||||
<Antd.Form.Item label={"Zero" |> E.ste}>
|
||||
<Antd_DatePicker
|
||||
value
|
||||
onChange={e => {
|
||||
e |> handleChange;
|
||||
|
||||
_ => ();
|
||||
}}
|
||||
/>
|
||||
</Antd.Form.Item>
|
||||
}
|
||||
/>
|
||||
<Form.Field
|
||||
field=FormConfig.Unit
|
||||
render={({handleChange, value}) =>
|
||||
<Antd.Form.Item label={"Unit" |> E.ste}>
|
||||
<Antd.Select value onChange={e => e |> handleChange}>
|
||||
<Antd.Select.Option value="days">
|
||||
{"days" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="hours">
|
||||
{"hours" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="milliseconds">
|
||||
{"milliseconds" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="minutes">
|
||||
{"minutes" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="months">
|
||||
{"months" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="quarters">
|
||||
{"quarters" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="seconds">
|
||||
{"seconds" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="weeks">
|
||||
{"weeks" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
<Antd.Select.Option value="years">
|
||||
{"years" |> E.ste}
|
||||
</Antd.Select.Option>
|
||||
</Antd.Select>
|
||||
</Antd.Form.Item>
|
||||
}
|
||||
/>
|
||||
<Antd.Form.Item>
|
||||
{reform.state.formState == Submitting
|
||||
? "Loading" |> E.ste
|
||||
|
|
Loading…
Reference in New Issue
Block a user