From 9fc4b369bf92243e53ee557bc2f327254a5c91ed Mon Sep 17 00:00:00 2001 From: Michael Harding Date: Thu, 29 Aug 2019 13:22:40 -0400 Subject: [PATCH] Clear security dropdown --- src/web/ui/src/Accounts/State.fs | 19 +++++++++++++------ src/web/ui/src/Accounts/View.fs | 10 +++++----- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/web/ui/src/Accounts/State.fs b/src/web/ui/src/Accounts/State.fs index bb6977189..48ac96fe1 100644 --- a/src/web/ui/src/Accounts/State.fs +++ b/src/web/ui/src/Accounts/State.fs @@ -362,6 +362,13 @@ let clearValidNewFills model = let clearManualFill model = {model with ManualFillData = {model.ManualFillData with newFills = clearValidNewFills model; updatedFills = []; deletedFills = {manualFill = Array.empty}}} +let validateManualFillQty value = + let nv = System.Int32.TryParse value + match value.Length, fst nv, snd nv with + | 0, _, _ -> true + | _, true, v when v > 0 -> true + | _, _, _ -> false + let update msg (model:Model) : Model * Cmd = match msg with | UpdateAdminData data -> @@ -611,12 +618,12 @@ let update msg (model:Model) : Model * Cmd = | Some f -> f let updatedFill = match place with - | "qty" -> { fill with qty = input} + | "qty" -> if (validateManualFillQty input) then { fill with qty = input} else fill | "price" -> { fill with price = input} | "side" -> { fill with side = input} | "user" -> { fill with user = input} - | "venue" -> { fill with venue = input} - | "symbol" -> { fill with symbol = input} + | "venue" -> { fill with venue = input; symbol = ""; SecurityId = "0" } + | "symbol" -> { fill with symbol = input; SecurityId = "0" } | "expiration" -> { fill with expiration = input} | "SecurityId" -> { fill with SecurityId = input} | _ -> fill @@ -632,12 +639,12 @@ let update msg (model:Model) : Model * Cmd = | Some f -> f let updatedFill = match place with - | "qty" -> { fill with qty = input} + | "qty" -> if (validateManualFillQty input) then { fill with qty = input} else fill | "price" -> { fill with price = input} | "side" -> { fill with side = input} | "user" -> { fill with user = input} - | "venue" -> { fill with venue = input} - | "symbol" -> { fill with symbol = input} + | "venue" -> { fill with venue = input; symbol = ""; SecurityId = "0" } + | "symbol" -> { fill with symbol = input; SecurityId = "0" } | "expiration" -> { fill with expiration = input} | "SecurityId" -> { fill with SecurityId = input} | _ -> fill diff --git a/src/web/ui/src/Accounts/View.fs b/src/web/ui/src/Accounts/View.fs index b584c5271..7f5dd72eb 100644 --- a/src/web/ui/src/Accounts/View.fs +++ b/src/web/ui/src/Accounts/View.fs @@ -901,10 +901,8 @@ let DayPositionView model dispatch = [ TableControl.Cell (Button.deleteButton Button.IsDisabled.Enabled (fun _ -> ((ulimit.id |> int), false)|> RemoveManualFill |> dispatch)) // TableControl.Cell (span [Style [Color "green"]][str (sprintf "%i" ulimit.id)]) - TableControl.Cell (str (venueToString securityMap.[limit.securityKey].venue)) - TableControl.Cell (str securityMap.[limit.securityKey].symbol) - // TableControl.Cell (Fields.simpleSelect "" venueList (ulimit.venue) (fun v -> (ulimit.id, v, "venue", false) |> UpdateManualFill |> dispatch)) - // TableControl.Cell (Fields.simpleSelect "" (getSymbolList model ulimit.venue) (ulimit.symbol) (fun v -> (ulimit.id, v, "symbol", false) |> UpdateManualFill |> dispatch)) + TableControl.Cell (Fields.simpleSelect "" venueList (ulimit.venue) (fun v -> (ulimit.id, v, "venue", false) |> UpdateManualFill |> dispatch)) + TableControl.Cell (Fields.simpleSelect "" (getSymbolList model ulimit.venue) (ulimit.symbol) (fun v -> (ulimit.id, v, "symbol", false) |> UpdateManualFill |> dispatch)) TableControl.Cell (Fields.tupleMapSelect "" (getPositionSecMap @@ -912,7 +910,9 @@ let DayPositionView model dispatch = (ulimit.venue) (ulimit.symbol) ) - (Some securityMap.[uint32 ulimit.SecurityId].securityName) + (match ulimit.SecurityId with + | "0" -> None + | _ -> Some securityMap.[uint32 ulimit.SecurityId].securityName) (Some ulimit.SecurityId) (fun v -> (ulimit.id, v, "SecurityId", false) |> UpdateManualFill |> dispatch) None