diff --git a/src/web/ui/src/Reports/State.fs b/src/web/ui/src/Reports/State.fs index 742be322e..a87bca7db 100644 --- a/src/web/ui/src/Reports/State.fs +++ b/src/web/ui/src/Reports/State.fs @@ -351,12 +351,11 @@ let update msg (model:Reports.Types.Model) : Model * Cmd = match pnlSorting with | None -> model.PnLSortDirection | Some record -> - let srt = (decodeUint8 record.value) - (fst srt, not <| snd srt) + (decodeUint8 record.value) { model with PnLColumns = newCols; PnLFilterValues = newFilterValues; PnLSortDirection = newSorting }, Cmd.batch ( - (Cmd.ofMsg (SetPnLSort <| fst newSorting ))::[ for f in newFilterValues do yield Cmd.ofMsg (SetPnLFilter (f.Key, f.Value))]) + (Cmd.ofMsg (SetPnLSort <| newSorting ))::[ for f in newFilterValues do yield Cmd.ofMsg (SetPnLFilter (f.Key, f.Value))]) | _ -> model, Cmd.Empty | RpcResponse str -> @@ -396,7 +395,7 @@ let update msg (model:Reports.Types.Model) : Model * Cmd = { model with mdRelayExpNameData = data; securityList = secs |> Map.ofList }, Cmd.batch ( selectSub None model :: - (Cmd.ofMsg (SetPnLSort <| fst model.PnLSortDirection )):: + (Cmd.ofMsg (SetPnLSort <| model.PnLSortDirection )):: [ for f in model.PnLFilterValues do yield Cmd.ofMsg (SetPnLFilter (f.Key, f.Value))]) | UpdateProducts data -> { model with mdRelayProductData = data}, Cmd.ofExistingPromise (requestExpNames model.mdRelay) id (box>>ErrorOccured) @@ -475,8 +474,10 @@ let update msg (model:Reports.Types.Model) : Model * Cmd = | true -> model, Cmd.ofMsg (SetPnLFilter (header, Empty)) | false -> model, Cmd.Empty - | SetPnLSort header -> + | SwitchPnLSort header -> let direction = fst <| model.PnLSortDirection <> header || not <| snd model.PnLSortDirection + model, Cmd.ofMsg <| SetPnLSort (header, direction) + | SetPnLSort (header, direction) -> let gSec = getSec <| model.securityList << uint32 let compStr (str1, str2) = diff --git a/src/web/ui/src/Reports/Types.fs b/src/web/ui/src/Reports/Types.fs index 379f6460f..3fb011383 100644 --- a/src/web/ui/src/Reports/Types.fs +++ b/src/web/ui/src/Reports/Types.fs @@ -43,7 +43,8 @@ type Msg = | UpdateProducts of Product[] | ChangePnLColumnVisibility of string * bool | SetPnLColumns of (string * bool) List - | SetPnLSort of string + | SwitchPnLSort of string + | SetPnLSort of string * bool | SetPnLTempFilter of string * ColFilter | SetPnLFilter of string * ColFilter | ClearPnLFilter of string diff --git a/src/web/ui/src/Reports/View.fs b/src/web/ui/src/Reports/View.fs index cf5f26980..233ce29a4 100644 --- a/src/web/ui/src/Reports/View.fs +++ b/src/web/ui/src/Reports/View.fs @@ -103,7 +103,7 @@ let PnLTabView (model:Model) (dispatch:Msg->Unit) = if visible then yield ( TableControl.Cell ( div [ ClassName "table-header" ] [ - span [ OnClick (fun _ -> header |> SetPnLSort |> dispatch)] [str <| sprintf "%s " header] + span [ OnClick (fun _ -> header |> SwitchPnLSort |> dispatch)] [str <| sprintf "%s " header] sortIcon header visible filterIcon header ])