Minor cleanup
This commit is contained in:
parent
d034e2a96f
commit
1a547748c7
|
@ -84,7 +84,8 @@ module ModelForm = {
|
|||
)
|
||||
|> ReasonReact.array}
|
||||
<div className="bg-green-100 p-2 rounded-sm mt-6 text-lg">
|
||||
{model.run(formState.combo) |> E.O.React.fmapOrNull(propValue)}
|
||||
{model.run(Prop.Combo.InputValues.toValueArray(formState.combo))
|
||||
|> E.O.React.fmapOrNull(propValue)}
|
||||
</div>
|
||||
</form>
|
||||
</div>;
|
||||
|
|
|
@ -226,7 +226,7 @@ module Model = {
|
|||
version: string,
|
||||
inputTypes: array(TypeWithMetadata.t),
|
||||
outputTypes: array(TypeWithMetadata.t),
|
||||
run: combo => option(Value.t),
|
||||
run: array(option(Value.t)) => option(Value.t),
|
||||
}
|
||||
and combo = {
|
||||
model: t,
|
||||
|
@ -237,11 +237,14 @@ module Model = {
|
|||
module InputTypes = {
|
||||
let keys = (t: t) =>
|
||||
t.inputTypes |> E.A.fmap((r: TypeWithMetadata.t) => r.id);
|
||||
|
||||
let getBy = (t: t, fn) => t.inputTypes |> E.A.getBy(_, fn);
|
||||
};
|
||||
};
|
||||
|
||||
module Combo = {
|
||||
type t = Model.combo;
|
||||
type valueArray = array(option(Value.t));
|
||||
|
||||
module InputValues = {
|
||||
let defaults = (t: Model.t) =>
|
||||
|
@ -258,10 +261,10 @@ module Combo = {
|
|||
let update = (t: t, key: string, onUpdate: option(Value.t)) =>
|
||||
ValueMap.update(t.inputValues, key, onUpdate);
|
||||
|
||||
let toValueArray = (t: t) => {
|
||||
let toValueArray = (t: t): valueArray => {
|
||||
t.model.inputTypes
|
||||
|> E.A.fmap((r: TypeWithMetadata.t) =>
|
||||
ValueMap.get(t.inputValues, r.id)
|
||||
t.inputValues->ValueMap.get(r.id)
|
||||
);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -151,8 +151,8 @@ module Interface = {
|
|||
| _ => PAYOUTS
|
||||
};
|
||||
|
||||
let run = (p: Prop.Combo.t) => {
|
||||
switch (Prop.Combo.InputValues.toValueArray(p)) {
|
||||
let run = (p: array(option(Prop.Value.t))) => {
|
||||
switch (p) {
|
||||
| [|
|
||||
Some(SelectSingle(fund)),
|
||||
Some(DateTime(intendedYear)),
|
||||
|
|
|
@ -16,8 +16,8 @@ module Model = {
|
|||
module Interface = {
|
||||
let dayKey = "Day";
|
||||
|
||||
let run = (p: Prop.Combo.t) => {
|
||||
switch (Prop.Combo.InputValues.toValueArray(p)) {
|
||||
let run = (p: array(option(Prop.Value.t))) => {
|
||||
switch (p) {
|
||||
| [|Some(DateTime(currentYear))|] => Some(Model.make(currentYear))
|
||||
| _ => None
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user