From 2d37f88553b71a8a2fc7106652ae4e900cab3bdd Mon Sep 17 00:00:00 2001 From: Jake Norbut Date: Tue, 15 May 2018 12:22:35 -0500 Subject: [PATCH] PR suggestion, thx John! --- src/client/spark/Orders/OrderPropertiesEditorVM.cs | 6 +----- src/client/spark/core/Utility/ViewModelBase.cs | 8 ++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/client/spark/Orders/OrderPropertiesEditorVM.cs b/src/client/spark/Orders/OrderPropertiesEditorVM.cs index f337fecc1..e61b72325 100644 --- a/src/client/spark/Orders/OrderPropertiesEditorVM.cs +++ b/src/client/spark/Orders/OrderPropertiesEditorVM.cs @@ -54,11 +54,7 @@ namespace mbts.spark { model.factory.subscribe_accounts(), order_properties.Select(ops => ops.account), () => string.Empty, - new PropertyValidation[] { - new PropertyValidation( - val => (!String.IsNullOrWhiteSpace(val) && accounts.Contains(val), "Please select an account") - ) - } + val => (!String.IsNullOrWhiteSpace(val) && accounts.Contains(val), "Please select an account") ); _time_in_force = backing( nameof(selected_time_in_force), diff --git a/src/client/spark/core/Utility/ViewModelBase.cs b/src/client/spark/core/Utility/ViewModelBase.cs index 9511b6c1a..48750c699 100644 --- a/src/client/spark/core/Utility/ViewModelBase.cs +++ b/src/client/spark/core/Utility/ViewModelBase.cs @@ -380,6 +380,14 @@ namespace mbts.ui.shell protected SelectorProperty backing(string name, IObservable> items, IObservable> desired_item, Func select_default, params Func[] validation_steps) => backing(name, items, desired_item, select_default, validation_steps.Select(v => new PropertyValidation(v)).ToList()); + /// + /// Returns a SelectorProperty<T> that observes an items source, and a desired item. When either observable ticks, it determines whether or not to assign the selected_item property. + /// This overload makes it a little easier to access the overload where a message is supplied to the validation logic. + /// Notes: If the user has selected an item (ie the selected_item has been assigned through the public setter), the desired item will be ignored unless force_override is true. + /// If the user has not selected an item, but the current items do not contain the desired item, it will re-evaluate whether or not to select the item when new items arrive. /// + protected SelectorProperty backing(string name, IObservable> items, IObservable> desired_item, Func select_default, params Func[] validation_steps) => + backing(name, items, desired_item, select_default, validation_steps.Select(v => new PropertyValidation(v)).ToList()); + /// /// Returns a SelectorProperty<T> that observes an items source, and a desired item. When either observable ticks, it determines whether or not to assign the selected_item property. /// Notes: If the user has selected an item (ie the selected_item has been assigned through the public setter), the desired item will be ignored unless force_override is true.