Adds spacer

This commit is contained in:
Roman Galochkin 2020-02-26 15:55:19 +03:00
parent b37d052b4f
commit 746d74da96
2 changed files with 192 additions and 122 deletions

View File

@ -40,6 +40,8 @@ module Styles = {
open Css;
let row =
style([display(`flex), selector("div > div", [flex(`num(1.))])]);
let form = style([backgroundColor(hex("eee")), padding(em(1.))]);
let spacer = style([marginTop(em(3.))]);
};
module FieldFloat = {
@ -70,8 +72,8 @@ let make = () => {
~initialState={
guesstimatorString: "mm(5 to 20, floor(normal(20,2)), [.5, .5])",
domainType: "Complete",
xPoint: "0.0",
excludingProbabilityMass: "",
xPoint: "50.0",
excludingProbabilityMass: "0.3",
unitType: "UnspecifiedDistribution",
zero: MomentRe.momentNow(),
unit: "days",
@ -84,125 +86,179 @@ let make = () => {
reform.submit();
};
<Form.Provider value=reform>
<Antd.Form onSubmit>
<FieldString
field=FormConfig.GuesstimatorString
label="GuesstimatorString"
/>
<div className=Styles.row>
<div>
<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>
}
/>
</div>
<div> <FieldString field=FormConfig.XPoint label="xPoint" /> </div>
<div>
<FieldString
field=FormConfig.ExcludingProbabilityMass
label="excludingProbabilityMass"
/>
</div>
</div>
<div className=Styles.row>
<div>
<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>
}
/>
</div>
<div>
<Form.Field
field=FormConfig.Zero
render={({handleChange, value}) =>
<Antd.Form.Item label={"Zero" |> E.ste}>
<Antd_DatePicker
value
onChange={e => {
e |> handleChange;
let domain =
switch (reform.state.values.domainType) {
| "Complete" => DistTypes.Complete
| "LeftLimited" =>
LeftLimited({
xPoint: reform.state.values.xPoint |> float_of_string,
excludingProbabilityMass:
reform.state.values.excludingProbabilityMass |> float_of_string,
})
| "RightLimited" =>
RightLimited({
xPoint: reform.state.values.xPoint |> float_of_string,
excludingProbabilityMass:
reform.state.values.excludingProbabilityMass |> float_of_string,
})
| "LeftAndRightLimited" =>
LeftAndRightLimited(
{
xPoint: reform.state.values.xPoint |> float_of_string,
excludingProbabilityMass:
reform.state.values.excludingProbabilityMass |> float_of_string,
},
{
xPoint: reform.state.values.xPoint |> float_of_string,
excludingProbabilityMass:
reform.state.values.excludingProbabilityMass |> float_of_string,
},
)
| _ => Js.Exn.raiseError("domain is unknown")
};
_ => ();
}}
/>
</Antd.Form.Item>
}
/>
</div>
<div>
<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>
}
/>
</div>
let unit =
switch (reform.state.values.unitType) {
| "UnspecifiedDistribution" => DistTypes.UnspecifiedDistribution
| "TimeDistribution" =>
TimeDistribution({
zero: reform.state.values.zero,
unit: reform.state.values.unit |> TimeTypes.TimeUnit.ofString,
})
| _ => Js.Exn.raiseError("unit is unknown")
};
let guesstimatorString = reform.state.values.guesstimatorString;
<div>
<div className=Styles.spacer />
<div>
<div>
{DistPlusIngredients.make(~guesstimatorString, ~domain, ~unit, ())
|> DistPlusIngredients.toDistPlus(
~sampleCount=10000,
~outputXYPoints=2000,
~truncateTo=Some(1000),
)
|> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
</div>
<Antd.Form.Item>
{reform.state.formState == Submitting
? "Loading" |> E.ste
: <Antd.Button _type=`primary onClick=onSubmit>
{"Submit" |> E.ste}
</Antd.Button>}
</Antd.Form.Item>
</Antd.Form>
</Form.Provider>;
</div>
<div className=Styles.spacer />
<div className=Styles.form>
<Form.Provider value=reform>
<Antd.Form onSubmit>
<FieldString
field=FormConfig.GuesstimatorString
label="Guesstimator String"
/>
<div className=Styles.row>
<div>
<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>
}
/>
</div>
<div> <FieldString field=FormConfig.XPoint label="xPoint" /> </div>
<div>
<FieldString
field=FormConfig.ExcludingProbabilityMass
label="excludingProbabilityMass"
/>
</div>
</div>
<div className=Styles.row>
<div>
<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>
}
/>
</div>
<div>
<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>
}
/>
</div>
<div>
<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>
}
/>
</div>
</div>
</Antd.Form>
</Form.Provider>
</div>
</div>;
};

View File

@ -33,6 +33,20 @@ module TimeUnit = {
| `weeks => "weeks"
| `years => "years"
};
let ofString = (timeUnit: string) =>
switch (timeUnit) {
| "days" => `days
| "hours" => `hours
| "milliseconds" => `milliseconds
| "minutes" => `minutes
| "months" => `months
| "quarters" => `quarters
| "seconds" => `seconds
| "weeks" => `weeks
| "years" => `years
| _ => Js.Exn.raiseError("TimeUnit is unknown")
};
};
module TimePoint = {