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 =
|
type route =
|
||||||
| Model(string)
|
| Model(string)
|
||||||
| FormBuilder
|
| DistBuilder
|
||||||
| Home
|
| Home
|
||||||
| NotFound;
|
| NotFound;
|
||||||
|
|
||||||
let routeToPath = route =>
|
let routeToPath = route =>
|
||||||
switch (route) {
|
switch (route) {
|
||||||
| Model(modelId) => "/m/" ++ modelId
|
| Model(modelId) => "/m/" ++ modelId
|
||||||
| FormBuilder => "/form-builder"
|
| DistBuilder => "/dist-builder"
|
||||||
| Home => "/"
|
| Home => "/"
|
||||||
| _ => "/"
|
| _ => "/"
|
||||||
};
|
};
|
||||||
|
@ -73,8 +73,8 @@ module Menu = {
|
||||||
</Item>
|
</Item>
|
||||||
})
|
})
|
||||||
|> ReasonReact.array}
|
|> ReasonReact.array}
|
||||||
<Item href={routeToPath(FormBuilder)} key="form-builder">
|
<Item href={routeToPath(DistBuilder)} key="dist-builder">
|
||||||
{"Form Builder" |> E.ste}
|
{"Dist Builder" |> E.ste}
|
||||||
</Item>
|
</Item>
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,7 @@ let make = () => {
|
||||||
let routing =
|
let routing =
|
||||||
switch (url.path) {
|
switch (url.path) {
|
||||||
| ["m", modelId] => Model(modelId)
|
| ["m", modelId] => Model(modelId)
|
||||||
| ["form-builder"] => FormBuilder
|
| ["dist-builder"] => DistBuilder
|
||||||
| [] => Home
|
| [] => Home
|
||||||
| _ => NotFound
|
| _ => NotFound
|
||||||
};
|
};
|
||||||
|
@ -100,7 +100,7 @@ let make = () => {
|
||||||
| Some(model) => <FormBuilder.ModelForm model key=id />
|
| Some(model) => <FormBuilder.ModelForm model key=id />
|
||||||
| None => <div> {"Page is not found" |> E.ste} </div>
|
| None => <div> {"Page is not found" |> E.ste} </div>
|
||||||
}
|
}
|
||||||
| FormBuilder => <div> {"Form Builder" |> E.ste} </div>
|
| DistBuilder => <DistBuilder />
|
||||||
| Home => <div> {"Welcome" |> E.ste} </div>
|
| Home => <div> {"Welcome" |> E.ste} </div>
|
||||||
| _ => <div> {"Page is not found" |> E.ste} </div>
|
| _ => <div> {"Page is not found" |> E.ste} </div>
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -2,9 +2,15 @@ open BsReform;
|
||||||
|
|
||||||
module FormConfig = [%lenses
|
module FormConfig = [%lenses
|
||||||
type state = {
|
type state = {
|
||||||
name: string,
|
guesstimatorString: string,
|
||||||
description: string,
|
//
|
||||||
picture: 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]
|
[@react.component]
|
||||||
let make = () => {
|
let make = () => {
|
||||||
let reform =
|
let reform =
|
||||||
|
@ -37,7 +61,15 @@ let make = () => {
|
||||||
~validationStrategy=OnDemand,
|
~validationStrategy=OnDemand,
|
||||||
~schema,
|
~schema,
|
||||||
~onSubmit=({state}) => {None},
|
~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>
|
<Form.Provider value=reform>
|
||||||
<Antd.Form onSubmit>
|
<Antd.Form onSubmit>
|
||||||
<FieldString field=FormConfig.Name label="Name" />
|
<FieldString
|
||||||
<FieldString field=FormConfig.Description label="Description" />
|
field=FormConfig.GuesstimatorString
|
||||||
<FieldString field=FormConfig.Picture label="Picture" />
|
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>
|
<Antd.Form.Item>
|
||||||
{reform.state.formState == Submitting
|
{reform.state.formState == Submitting
|
||||||
? "Loading" |> E.ste
|
? "Loading" |> E.ste
|
||||||
|
|
Loading…
Reference in New Issue
Block a user