From ddc297d413a10f1852b3c7ef4aaaebf3ea050b53 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 12 Nov 2018 00:34:14 -0600 Subject: [PATCH] OrderPropertiesEditor - open algo popup when user selects new algo --- src/client/spark/Orders/OrderPropertiesEditorVM.cs | 6 ++++++ src/client/spark/core/Utility/ViewModelBase.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/client/spark/Orders/OrderPropertiesEditorVM.cs b/src/client/spark/Orders/OrderPropertiesEditorVM.cs index 919ee29f8..f6e62e9e0 100644 --- a/src/client/spark/Orders/OrderPropertiesEditorVM.cs +++ b/src/client/spark/Orders/OrderPropertiesEditorVM.cs @@ -173,6 +173,12 @@ namespace mbts.spark { _order_type_param_errors_sub = ndei.subscribe_errors_changed((s, e) => assert_no_param_errors()); void assert_no_param_errors() => assert(!ndei.HasErrors, "order type pararmeters invalid."); } + /// This is a bit of a hack; the goal is to open the algo popup menu when users select a new algo. + /// It isn't as straightforward as it sounds bc there are a couple non-user-invoked scenarios which ellicit calls to the SelectorProperty.selected_item's public setter: + /// 1) a selected-order-type default value is observed from an IObservable settings source, which may overwrite the current selection, esp if the current value is null. + /// 2) the order-type itemssource is observed from an IObservable settings source as well, which may cause the current selection to be changed by the view, if the itemssource no longer contains the currently selected value. + if (new_val != null && new_val == selected_order_type && _order_type.items.Contains(new_val) && selected_order_type.has_editable_properties && _order_type.is_user_selected_item && old_val != null && _order_type.items.Contains(old_val)) + selected_order_type.editable_properties_open = true; } } } diff --git a/src/client/spark/core/Utility/ViewModelBase.cs b/src/client/spark/core/Utility/ViewModelBase.cs index 317393440..4fc10e28d 100644 --- a/src/client/spark/core/Utility/ViewModelBase.cs +++ b/src/client/spark/core/Utility/ViewModelBase.cs @@ -630,6 +630,7 @@ namespace mbts.ui.shell _set_selected_item(value); } } + public bool is_user_selected_item => _is_user_selected_item; public IDisposable Subscribe(IObserver<(TValue oldval, TValue newval)> observer) { Changed += pch;