SP-54: Clear filters and ui refinement
This commit is contained in:
1 parent
4268604cb6
commit
bce4dcbc5d
4 files changed
+55
-29
No files matched your search
@@ -116,17 +116,16 @@ let showFilter (content:ReactElement) (onApplyClick: MouseEvent -> Unit) (onClea
|
||||
div [ Class "modal-background clear-background"; OnClick onCloseClick ][ ]
|
||||
div [ Class "card filter-card"; Style [ Top top; Left left ] ]
|
||||
[ div [ Class "card-content" ]
|
||||
[ button [ Class "delete"; OnClick onCloseClick ] [ ]
|
||||
content
|
||||
[ content
|
||||
]
|
||||
footer [ Class "card-footer" ]
|
||||
[ p [ Class "card-footer-item" ]
|
||||
[ p [ Class "card-footer-item"; OnClick onApplyClick ]
|
||||
[ span [ ]
|
||||
[ a [ OnClick onApplyClick ]
|
||||
[ a [ ]
|
||||
[ str "Apply" ] ] ]
|
||||
p [ Class "card-footer-item" ]
|
||||
p [ Class "card-footer-item"; OnClick onClearClick ]
|
||||
[ span [ ]
|
||||
[ a [ OnClick onClearClick ]
|
||||
[ a [ ]
|
||||
[ str "Clear" ] ] ] ] ]
|
||||
]
|
||||
|
||||
|
||||
@@ -260,6 +260,12 @@ let getValFromPNLUnit header (data:PNLUnit) (securityList: Map<uint32, PositionS
|
||||
| "CPP" -> "", data.cashValue
|
||||
| _ -> "", 0.0
|
||||
|
||||
let filterIsDefault filter =
|
||||
match filter with
|
||||
| StringSearch s -> s = ""
|
||||
| NumberRange (min, max) -> min = Double.MinValue && max = Double.MaxValue
|
||||
| Empty -> true
|
||||
|
||||
let update msg (model:Reports.Types.Model) : Model * Cmd<Msg> =
|
||||
match msg with
|
||||
| UpdateAdminData adm ->
|
||||
@@ -337,24 +343,45 @@ let update msg (model:Reports.Types.Model) : Model * Cmd<Msg> =
|
||||
{model with FilterOpen = (isOpen, loca); TempFilter = (header, newFilter)}, Cmd.ofMsg (SetPnLTempFilter (header, newFilter))
|
||||
|
||||
| SetPnLFilter (header, filter) ->
|
||||
let newFilterValues =
|
||||
match Map.containsKey header model.PnLFilterValues with
|
||||
| true -> (Map.remove header model.PnLFilterValues).Add(header, filter)
|
||||
| false -> model.PnLFilterValues.Add(header, filter)
|
||||
match filterIsDefault filter with
|
||||
| true ->
|
||||
let newFilterValues =
|
||||
match Map.containsKey header model.PnLFilterValues with
|
||||
| true -> (Map.remove header model.PnLFilterValues)
|
||||
| false -> model.PnLFilterValues
|
||||
|
||||
let newFilter =
|
||||
match filter with
|
||||
| StringSearch s ->
|
||||
function pnl ->
|
||||
let v = (getValFromPNLUnit header pnl (Some model.securityList)) |> fst
|
||||
if s.Trim() = "" || v.ToLower().Contains (s.Trim().ToLower()) then Some pnl else None
|
||||
| NumberRange (min, max) ->
|
||||
function pnl ->
|
||||
let curVal = (getValFromPNLUnit header pnl None) |> snd
|
||||
if (min <= curVal && curVal <= max) then Some pnl else None
|
||||
| Empty -> Some
|
||||
let newMap = model.PnLFilter.Add (header, newFilter)
|
||||
{ model with PnLFilter = newMap; PnLFilterValues = newFilterValues }, ("", false, Wherever) |> ShowFilterBox |> Cmd.ofMsg
|
||||
let newMap =
|
||||
match Map.containsKey header model.PnLFilter with
|
||||
| true -> Map.remove header model.PnLFilter
|
||||
| false -> model.PnLFilter
|
||||
|
||||
{ model with PnLFilter = newMap; PnLFilterValues = newFilterValues }, ("", false, Wherever) |> ShowFilterBox |> Cmd.ofMsg
|
||||
| false ->
|
||||
let newFilterValues =
|
||||
match Map.containsKey header model.PnLFilterValues with
|
||||
| true -> (Map.remove header model.PnLFilterValues).Add(header, filter)
|
||||
| false -> model.PnLFilterValues.Add(header, filter)
|
||||
|
||||
let newFilter =
|
||||
match filter with
|
||||
| StringSearch s ->
|
||||
function pnl ->
|
||||
let v = (getValFromPNLUnit header pnl (Some model.securityList)) |> fst
|
||||
if s.Trim() = "" || v.ToLower().Contains (s.Trim().ToLower()) then Some pnl else None
|
||||
| NumberRange (min, max) ->
|
||||
function pnl ->
|
||||
let curVal = (getValFromPNLUnit header pnl None) |> snd
|
||||
if (min <= curVal && curVal <= max) then Some pnl else None
|
||||
| Empty -> Some
|
||||
|
||||
let newMap = model.PnLFilter.Add (header, newFilter)
|
||||
|
||||
{ model with PnLFilter = newMap; PnLFilterValues = newFilterValues }, ("", false, Wherever) |> ShowFilterBox |> Cmd.ofMsg
|
||||
|
||||
| ClearPnLFilter header ->
|
||||
match Map.containsKey header model.PnLFilterValues with
|
||||
| true -> model, Cmd.ofMsg (SetPnLFilter (header, Empty))
|
||||
| false -> model, Cmd.Empty
|
||||
|
||||
| SetPnLSort header ->
|
||||
Browser.console.log header
|
||||
|
||||
@@ -42,7 +42,7 @@ type Msg =
|
||||
| SetPnLSort of string
|
||||
| SetPnLTempFilter of string * ColFilter
|
||||
| SetPnLFilter of string * ColFilter
|
||||
//| ClearPnLFilter of string
|
||||
| ClearPnLFilter of string
|
||||
| ShowGridSettings of bool
|
||||
| ShowFilterBox of string * bool * Location
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ let PnLTabView (model:Model) (dispatch:Msg->Unit) =
|
||||
Fields.text "Search:" (searchStr) [] (fun v -> (filterHeader, StringSearch v) |> SetPnLTempFilter |> dispatch)
|
||||
])
|
||||
(fun _ -> (filterHeader, filterType) |> SetPnLFilter |> dispatch)
|
||||
(fun _ -> ("", false, Wherever) |> ShowFilterBox |> dispatch)
|
||||
(fun _ -> filterHeader |> ClearPnLFilter |> dispatch)
|
||||
(fun _ -> ("", false, Wherever) |> ShowFilterBox |> dispatch)
|
||||
(sprintf "%fpx" (where |> snd)) (sprintf "%fpx" (where |> fst))
|
||||
| NumberRange (min, max), true ->
|
||||
@@ -83,12 +83,12 @@ let PnLTabView (model:Model) (dispatch:Msg->Unit) =
|
||||
| _, _ -> i [ ClassName (sprintf "fa fa-sort header-icon-hidden")] [ ]
|
||||
|
||||
let filterIcon header =
|
||||
let clsStr = match Map.containsKey header model.PnLFilterValues || (fst model.TempFilter) = header with
|
||||
| true -> "fa fa-filter header-filter-icon yellow"
|
||||
| false -> "fa fa-filter header-filter-icon header-icon-hidden"
|
||||
let classStr = match Map.containsKey header model.PnLFilterValues || (fst model.TempFilter) = header with
|
||||
| true -> "fa fa-filter header-filter-icon yellow"
|
||||
| false -> "fa fa-filter header-filter-icon header-icon-hidden"
|
||||
let mutable origin = Location (0.0, 0.0)
|
||||
i [
|
||||
ClassName (clsStr)
|
||||
ClassName (classStr)
|
||||
Ref (fun me ->
|
||||
if me <> null then
|
||||
let r = me.getBoundingClientRect()
|
||||
|
||||
Reference in new issue
Block a user