From 2c07167c161cb56fb0e336b89467b2340d600f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Sun, 5 Jun 2022 20:34:21 +0200 Subject: [PATCH] #383 - Refactor save methods. --- .../Pages/Users/Settings.razor | 4 +-- .../Pages/Users/Settings.razor.cs | 28 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/Money.Blazor.Host/Pages/Users/Settings.razor b/src/Money.Blazor.Host/Pages/Users/Settings.razor index ac0c52c5..a6727e93 100644 --- a/src/Money.Blazor.Host/Pages/Users/Settings.razor +++ b/src/Money.Blazor.Host/Pages/Users/Settings.razor @@ -62,7 +62,7 @@ } - + @@ -88,6 +88,6 @@ - + \ No newline at end of file diff --git a/src/Money.Blazor.Host/Pages/Users/Settings.razor.cs b/src/Money.Blazor.Host/Pages/Users/Settings.razor.cs index 051ca197..f114e5be 100644 --- a/src/Money.Blazor.Host/Pages/Users/Settings.razor.cs +++ b/src/Money.Blazor.Host/Pages/Users/Settings.razor.cs @@ -92,20 +92,6 @@ private T AddProperty(string name, string title, Action edit, string defaultV return (T)viewModel; } - protected async Task SetMobileMenuAsync() - { - MobileMenu.CurrentValue = String.Join(",", MobileMenu.AvailableModels.Where(m => MobileMenu.SelectedIdentifiers.Contains(m.Identifier)).Select(m => m.Identifier)); - await MobileMenu.SetAsync(); - MobileMenuEditor.Hide(); - } - - protected async Task SetSummarySortAsync() - { - SummarySort.CurrentValue = $"{SummarySort.Property}-{SummarySort.Direction}"; - await SummarySort.SetAsync(); - SummarySortEditor.Hide(); - } - Task IEventHandler.HandleAsync(UserPropertyChanged payload) { var viewModel = ViewModels.FirstOrDefault(vm => vm.Key == payload.PropertyKey); @@ -154,7 +140,7 @@ public string CurrentValue set => currentValue = value; } - public async Task SetAsync() + public virtual async Task SetAsync() { Console.WriteLine($"Current '{currentValue}', ModelValue '{Model?.Value}'."); @@ -187,6 +173,12 @@ public async override Task InitializeAsync() ? CurrentValue.Split(',').ToList() : new List(0); } + + public override Task SetAsync() + { + CurrentValue = String.Join(",", AvailableModels.Where(m => SelectedIdentifiers.Contains(m.Identifier)).Select(m => m.Identifier)); + return base.SetAsync(); + } } public class SortPropertyViewModel : PropertyViewModel @@ -214,5 +206,11 @@ public async override Task InitializeAsync() Direction = Enum.Parse(parts[1]); } } + + public override Task SetAsync() + { + CurrentValue = $"{Property}-{Direction}"; + return base.SetAsync(); + } } }