diff --git a/src/client/spark/Modules/Trading/Fills/FillsWindowFactory.cs b/src/client/spark/Modules/Trading/Fills/FillsWindowFactory.cs
index 939bef5a0..ce49d6e87 100644
--- a/src/client/spark/Modules/Trading/Fills/FillsWindowFactory.cs
+++ b/src/client/spark/Modules/Trading/Fills/FillsWindowFactory.cs
@@ -20,6 +20,27 @@ namespace bts.shell {
readonly IBus _bus;
readonly OrdersModel _orders_model;
readonly UserSettingsHub _settings_hub;
+ /// Fills 'sorting-criterion' settings were compromised a while back (mid-late 2018).
+ /// The issue was that, when a column was sorted, its 'sort member path' was assigned to the SortingCriteria.col_name,
+ /// rather than the enum/id string.
+ /// This dictionary serves as a reverse-lookup so the sort member path can be converted to the enum/id string.
+ static readonly IReadOnlyDictionary _sort_member_to_id =
+ new Dictionary {
+ { nameof(FillsVM.Row.account), Columns.Account },
+ { nameof(FillsVM.Row.exchange), Columns.Exchange },
+ { nameof(FillsVM.Row.fill_key), Columns.FillKey },
+ { nameof(FillsVM.Row.fill_kind), Columns.FillKind },
+ { nameof(FillsVM.Row.fill_time), Columns.FillTime },
+ { nameof(FillsVM.Row.order_key), Columns.OrderKey },
+ { nameof(FillsVM.Row.order_type), Columns.OrderType },
+ { nameof(FillsVM.Row.price), Columns.Price },
+ { nameof(FillsVM.Row.security), Columns.Security },
+ { nameof(FillsVM.Row.security_key), Columns.SecurityKey },
+ { nameof(FillsVM.Row.side), Columns.Side },
+ { nameof(FillsVM.Row.size), Columns.Size },
+ { nameof(FillsVM.Row.time_in_force), Columns.TimeInForce },
+ { nameof(FillsVM.Row.user), Columns.User }
+ };
public FillsWindowFactory(TradingShellModule module, IBus bus, UserSettingsHub settings_hub, OrdersModel orders_model)
: base(module, "Fills") {
@@ -38,6 +59,7 @@ namespace bts.shell {
_bus.post(SparkTags.ShowWindow, await load(state));
IShellWindow _create(StartupData state) {
+ GridSettingsHelper.normalize_sorting_criterion(state.sorting_criterion, _sort_member_to_id);
var settings_manager = new WindowSettingsManager(_settings_hub,
state.grid,
get: us => us.fills_grid,
diff --git a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookSettings.cs b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookSettings.cs
index d15c1c303..6599fa93f 100644
--- a/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookSettings.cs
+++ b/src/client/spark/Modules/Trading/OrderBook/Settings/OrderBookSettings.cs
@@ -99,8 +99,11 @@ namespace bts.shell.orderbook {
public OrderBookGridSettings grid_settings_wrapper() {
if (use_defaults)
return null;
- if (orderbook_grid == null)
- orderbook_grid = new OrderBookGridSettings(grid.clone(), _predicate_animations);
+ if (orderbook_grid == null) {
+ if (grid == null)
+ grid = _default_general_grid;
+ orderbook_grid = new OrderBookGridSettings(grid.clone(), _predicate_animations);
+ }
return orderbook_grid;
}
#pragma warning restore CS0612 // Type or member is obsolete
diff --git a/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsHelper.cs b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsHelper.cs
new file mode 100644
index 000000000..a5e8c4dec
--- /dev/null
+++ b/src/client/spark/view/Controls/DIYGrid/Settings/GridSettingsHelper.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace mbts.ui.settings {
+ static class GridSettingsHelper {
+ public static TColKey? parse_col_id(string id) where TColKey : struct =>
+ Enum.TryParse(id, true, out TColKey key) ? key : (TColKey?)null;
+
+ public static string fmt_col_id(TColKey key) where TColKey : struct =>
+ key.ToString();
+
+ public static void normalize_sorting_criterion(IEnumerable sorting_criterion, IReadOnlyDictionary sort_member_to_id) where TColKey : struct =>
+ normalize_sorting_criterion(sorting_criterion, new Func[] {
+ parse_col_id,
+ col_name => sort_member_to_id.TryGetValue(col_name, out var k) ? k : (TColKey?)null
+ });
+
+ public static void normalize_sorting_criterion(IEnumerable sorting_criterion, IEnumerable> conversion_dels) where TColKey : struct {
+ foreach (var sc in sorting_criterion) {
+ sc.col_name = conversion_dels
+ .Select(del => del(sc.col_name))
+ .FirstOrDefault(k => k.HasValue)?.ToString() ?? sc.col_name;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridSortManager.cs b/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridSortManager.cs
index 47c87c5e3..689679c22 100644
--- a/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridSortManager.cs
+++ b/src/client/spark/view/Controls/DIYGrid/Utils/DIYGridSortManager.cs
@@ -1,5 +1,8 @@
-using bts.utils;
+using bts;
+using bts.collections;
+using bts.utils;
using mbts.collections;
+using mbts.ui.settings;
using mbts.ui.utility;
using mbts.utils;
using System;
@@ -51,8 +54,17 @@ namespace mbts.ui.controls {
).to_comparer();
}
- public void load_from(IEnumerable sorting_criterion) =>
- _on_settings(sorting_criterion.Select(sc => (EnumHelper.parse(sc.col_name), sc.is_ascending ? ListSortDirection.Ascending : ListSortDirection.Descending)));
+ public void load_from(IEnumerable sorting_criterion) {
+ var sort_member_to_id = _map
+ .Where(kv => !string.IsNullOrEmpty(kv.Value.col.sort_member_path))
+ .Distinct()
+ .ToDictionary(kv => kv.Value.col.sort_member_path, kv => kv.Key);
+ GridSettingsHelper.normalize_sorting_criterion(sorting_criterion, sort_member_to_id);
+ _on_settings(sorting_criterion
+ .Select(sc => (GridSettingsHelper.parse_col_id(sc.col_name), sc.is_ascending ? ListSortDirection.Ascending : ListSortDirection.Descending))
+ .Where(t => t.Item1.HasValue)
+ .Select(t => (t.Item1.Value, t.Item2)));
+ }
public IEnumerable create() =>
_active_cols.AsCollection().Select(t => new SortingCriteria(t.col.id, t.direction == ListSortDirection.Ascending));