diff --git a/src/Money.Api/appsettings.json b/src/Money.Api/appsettings.json index 52f3de01..1d1b410e 100644 --- a/src/Money.Api/appsettings.json +++ b/src/Money.Api/appsettings.json @@ -14,5 +14,5 @@ "RequireUppercase": false } }, - "UserProperties": [ "PriceDecimalDigits", "DateFormat", "MobileMenu", "SummarySort", "ExpenseOverviewSort" ] + "UserProperties": [ "PriceDecimalDigits", "DateFormat", "MobileMenu", "SummarySort", "ExpenseOverviewSort", "SearchSort" ] } diff --git a/src/Money.Blazor.Host/Pages/Overview.razor.cs b/src/Money.Blazor.Host/Pages/Overview.razor.cs index ced43a12..df197942 100644 --- a/src/Money.Blazor.Host/Pages/Overview.razor.cs +++ b/src/Money.Blazor.Host/Pages/Overview.razor.cs @@ -6,8 +6,8 @@ using Money.Models.Loading; using Money.Models.Queries; using Money.Models.Sorting; -using Money.Services; using Money.Queries; +using Money.Services; using Neptuo; using Neptuo.Commands; using Neptuo.Events; diff --git a/src/Money.Blazor.Host/Pages/Search.razor.cs b/src/Money.Blazor.Host/Pages/Search.razor.cs index 254cff4c..70824992 100644 --- a/src/Money.Blazor.Host/Pages/Search.razor.cs +++ b/src/Money.Blazor.Host/Pages/Search.razor.cs @@ -5,6 +5,7 @@ using Money.Models.Loading; using Money.Models.Queries; using Money.Models.Sorting; +using Money.Queries; using Money.Services; using Neptuo.Events; using Neptuo.Events.Handlers; @@ -25,8 +26,6 @@ public partial class Search : System.IDisposable, IEventHandler, IEventHandler { - public static readonly SortDescriptor DefaultSort = new SortDescriptor(OutcomeOverviewSortType.ByWhen, SortDirection.Descending); - public CurrencyFormatter CurrencyFormatter { get; private set; } [Inject] @@ -46,6 +45,8 @@ public partial class Search : System.IDisposable, protected ElementReference SearchBox { get; set; } + protected SortDescriptor DefaultSort { get; set; } + protected LoadingContext Loading { get; } = new LoadingContext(); protected SortDescriptor Sort { get; set; } protected PagingContext PagingContext { get; set; } @@ -56,6 +57,7 @@ public partial class Search : System.IDisposable, protected async override Task OnInitializedAsync() { + DefaultSort = await Queries.QueryAsync(new GetSearchSortProperty()); FormSort = Sort = DefaultSort; PagingContext = new PagingContext(LoadPageAsync, Loading); CurrencyFormatter = await CurrencyFormatterFactory.CreateAsync(); diff --git a/src/Money.Blazor.Host/Pages/Users/Settings.razor b/src/Money.Blazor.Host/Pages/Users/Settings.razor index f5ba42dd..9f104b55 100644 --- a/src/Money.Blazor.Host/Pages/Users/Settings.razor +++ b/src/Money.Blazor.Host/Pages/Users/Settings.razor @@ -59,4 +59,8 @@ + + + + \ 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 78741d37..8c2aca11 100644 --- a/src/Money.Blazor.Host/Pages/Users/Settings.razor.cs +++ b/src/Money.Blazor.Host/Pages/Users/Settings.razor.cs @@ -49,6 +49,9 @@ public partial class Settings : System.IDisposable, protected SortPropertyViewModel ExpenseOverviewSort { get; set; } protected PropertyDialog ExpenseOverviewSortEditor { get; set; } + protected SortPropertyViewModel SearchSort { get; set; } + protected PropertyDialog SearchSortEditor { get; set; } + protected List Models { get; set; } protected List ViewModels { get; } = new List(); @@ -63,6 +66,7 @@ protected async override Task OnInitializedAsync() MobileMenu = AddProperty("MobileMenu", "Mobile menu", () => MobileMenuEditor.Show(), icon: "mobile"); SummarySort = AddProperty>("SummarySort", "Summary sort", () => SummarySortEditor.Show(), icon: "sort-alpha-down", defaultValue: "ByCategory-Ascending"); ExpenseOverviewSort = AddProperty>("ExpenseOverviewSort", "Expense overview sort", () => ExpenseOverviewSortEditor.Show(), icon: "sort-alpha-down", defaultValue: "ByWhen-Descending"); + SearchSort = AddProperty>("SearchSort", "Search sort", () => SearchSortEditor.Show(), icon: "sort-alpha-down", defaultValue: "ByWhen-Descending"); await LoadAsync(); } diff --git a/src/Money.Blazor.Host/Queries/GetSearchSortProperty.cs b/src/Money.Blazor.Host/Queries/GetSearchSortProperty.cs new file mode 100644 index 00000000..9dfbfa84 --- /dev/null +++ b/src/Money.Blazor.Host/Queries/GetSearchSortProperty.cs @@ -0,0 +1,19 @@ +using Money.Models; +using Money.Models.Sorting; +using Money.Pages; +using Neptuo.Queries; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Money.Queries +{ + /// + /// A query for getting a sort descriptor for expense overview. + /// + public class GetSearchSortProperty : IQuery> + { } +} diff --git a/src/Money.Blazor.Host/Services/UserPropertyQueryHandler.cs b/src/Money.Blazor.Host/Services/UserPropertyQueryHandler.cs index df1ea92b..ffe1d3d8 100644 --- a/src/Money.Blazor.Host/Services/UserPropertyQueryHandler.cs +++ b/src/Money.Blazor.Host/Services/UserPropertyQueryHandler.cs @@ -37,6 +37,10 @@ public async Task ExecuteAsync(object query, HttpQueryDispatcher dispatc { return await GetSortDescriptorAsync(dispatcher, "ExpenseOverviewSort", "ByWhen-Descending"); } + else if (query is GetSearchSortProperty) + { + return await GetSortDescriptorAsync(dispatcher, "SearchSort", "ByWhen-Descending"); + } return await next(query); }