Minor cleanup

This commit is contained in:
Ozzie Gooen 2020-02-17 16:53:30 +00:00
parent d034e2a96f
commit 1a547748c7
4 changed files with 12 additions and 8 deletions

View File

@ -84,7 +84,8 @@ module ModelForm = {
) )
|> ReasonReact.array} |> ReasonReact.array}
<div className="bg-green-100 p-2 rounded-sm mt-6 text-lg"> <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> </div>
</form> </form>
</div>; </div>;

View File

@ -226,7 +226,7 @@ module Model = {
version: string, version: string,
inputTypes: array(TypeWithMetadata.t), inputTypes: array(TypeWithMetadata.t),
outputTypes: array(TypeWithMetadata.t), outputTypes: array(TypeWithMetadata.t),
run: combo => option(Value.t), run: array(option(Value.t)) => option(Value.t),
} }
and combo = { and combo = {
model: t, model: t,
@ -237,11 +237,14 @@ module Model = {
module InputTypes = { module InputTypes = {
let keys = (t: t) => let keys = (t: t) =>
t.inputTypes |> E.A.fmap((r: TypeWithMetadata.t) => r.id); t.inputTypes |> E.A.fmap((r: TypeWithMetadata.t) => r.id);
let getBy = (t: t, fn) => t.inputTypes |> E.A.getBy(_, fn);
}; };
}; };
module Combo = { module Combo = {
type t = Model.combo; type t = Model.combo;
type valueArray = array(option(Value.t));
module InputValues = { module InputValues = {
let defaults = (t: Model.t) => let defaults = (t: Model.t) =>
@ -258,10 +261,10 @@ module Combo = {
let update = (t: t, key: string, onUpdate: option(Value.t)) => let update = (t: t, key: string, onUpdate: option(Value.t)) =>
ValueMap.update(t.inputValues, key, onUpdate); ValueMap.update(t.inputValues, key, onUpdate);
let toValueArray = (t: t) => { let toValueArray = (t: t): valueArray => {
t.model.inputTypes t.model.inputTypes
|> E.A.fmap((r: TypeWithMetadata.t) => |> E.A.fmap((r: TypeWithMetadata.t) =>
ValueMap.get(t.inputValues, r.id) t.inputValues->ValueMap.get(r.id)
); );
}; };
}; };

View File

@ -151,8 +151,8 @@ module Interface = {
| _ => PAYOUTS | _ => PAYOUTS
}; };
let run = (p: Prop.Combo.t) => { let run = (p: array(option(Prop.Value.t))) => {
switch (Prop.Combo.InputValues.toValueArray(p)) { switch (p) {
| [| | [|
Some(SelectSingle(fund)), Some(SelectSingle(fund)),
Some(DateTime(intendedYear)), Some(DateTime(intendedYear)),

View File

@ -16,8 +16,8 @@ module Model = {
module Interface = { module Interface = {
let dayKey = "Day"; let dayKey = "Day";
let run = (p: Prop.Combo.t) => { let run = (p: array(option(Prop.Value.t))) => {
switch (Prop.Combo.InputValues.toValueArray(p)) { switch (p) {
| [|Some(DateTime(currentYear))|] => Some(Model.make(currentYear)) | [|Some(DateTime(currentYear))|] => Some(Model.make(currentYear))
| _ => None | _ => None
}; };