SPARK-1678: Refresh orders after one second (cherry picked)

This commit is contained in:
Michael Harding committed 2018-11-08 12:12:44 -05:00
1 parent 088377582d
commit 79ec41556e
3 files changed
+20 -4

No files matched your search

+9 -1
View File
@@ -7,6 +7,7 @@ open Fable.PowerPack.PromiseImpl
open Fable.Import
open bts.co2
open Fable
open Fable.PowerPack
let isNewAccount (account:BTSAccount) =
account.id = 0u && account.isPresent
@@ -171,7 +172,14 @@ let update msg (model:Model) : Model * Cmd<Msg> =
| UpdateOrdersData summary ->
{model with ordersData = List.ofArray summary.units}, Cmd.Empty
| CancelOrders orders ->
model, Cmd.ofExistingPromise (cancelOrders model.admin model.scratch.name orders) id (box>>ErrorOccured)
{ model with ConfirmModal = ("", Msg.SelectTab model.tab); SelectedOrders = [] },
Cmd.batch [
Cmd.ofExistingPromise (cancelOrders model.admin model.scratch.name orders) id (box>>ErrorOccured)
Cmd.ofExistingPromise (promise {
do! Promise.sleep 1000
return GetOrdersData
}) id (fun _ -> GetOrdersData)
]
| SelectOrder (chckd, orders) ->
let so = match chckd, orders with
| true, h::m::tail -> orders
+2 -1
View File
@@ -43,11 +43,12 @@ type SIMExchangeField =
type Msg =
| UpdateAdminData of AdminData
| NoAdminData of string
// Orders
| GetOrdersData
| UpdateOrdersData of OrdersSummary
| SelectOrder of bool * OrdersSummaryUnit list
| CancelOrders of OrdersSummaryUnit list
| NoAdminData of string
| SelectAccount of BTSAccount
| DeleteAccount of BTSAccount
| AddAccount
+9 -2
View File
@@ -78,7 +78,6 @@ let generalView model dispatch =
]
let GetSymbolArray (model:Model) =
Array.map<bts.api.Product, string> (fun a -> a.symbol ) model.mdRelayProductData
|> Array.distinct
@@ -125,7 +124,15 @@ let ordersView (model:Model) dispatch =
}
]
let cancelButton = Button.button "Cancel Selected Orders" "is-danger" "times" Button.Enabled (fun _ -> model.SelectedOrders |> CancelOrders |> dispatch)
let enableCancel =
match model.SelectedOrders.Length with
| 0 -> Button.Disabled
| _ -> Button.Enabled
let cancelMessage = model.SelectedOrders |> CancelOrders
let confirmText = sprintf "Are you sure you want to cancel all orders in %s for users: %s?" model.scratch.name (String.concat ", " (List.map (fun (elm:OrdersSummaryUnit) -> elm.user) model.SelectedOrders))
let cancelButton = Button.button "Cancel Selected Orders" "is-danger" "times" enableCancel (fun _ -> OpenConfirmModal (confirmText, cancelMessage) |> dispatch)
let reloadFun = fun _ -> dispatch (SelectTab model.tab)
div [][
TableControl.createDataTable (Some headerRow) rws cancelButton