From 3e099988bca43ee74ac21fbedd0a0f155381bec9 Mon Sep 17 00:00:00 2001 From: troogs Date: Thu, 16 Apr 2026 19:36:26 +0200 Subject: [PATCH] Add ProspectSortOption enum and implement sorting dialog with buttons --- .../Enums/ProspectSortOption.cs | 10 +++++ .../Dialogs/ProspectSortDialog.razor | 9 +++++ .../Dialogs/ProspectSortDialog.razor.cs | 39 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 FoodsharingSiegen.Contracts/Enums/ProspectSortOption.cs create mode 100644 FoodsharingSiegen.Server/Dialogs/ProspectSortDialog.razor create mode 100644 FoodsharingSiegen.Server/Dialogs/ProspectSortDialog.razor.cs diff --git a/FoodsharingSiegen.Contracts/Enums/ProspectSortOption.cs b/FoodsharingSiegen.Contracts/Enums/ProspectSortOption.cs new file mode 100644 index 0000000..d9f174f --- /dev/null +++ b/FoodsharingSiegen.Contracts/Enums/ProspectSortOption.cs @@ -0,0 +1,10 @@ +namespace FoodsharingSiegen.Contracts.Enums +{ + public enum ProspectSortOption + { + NameAscending, + NameDescending, + ModifiedAscending, + ModifiedDescending + } +} diff --git a/FoodsharingSiegen.Server/Dialogs/ProspectSortDialog.razor b/FoodsharingSiegen.Server/Dialogs/ProspectSortDialog.razor new file mode 100644 index 0000000..e18bb47 --- /dev/null +++ b/FoodsharingSiegen.Server/Dialogs/ProspectSortDialog.razor @@ -0,0 +1,9 @@ +@inherits FsBase +@using FoodsharingSiegen.Contracts.Enums + +
+ + + + +
diff --git a/FoodsharingSiegen.Server/Dialogs/ProspectSortDialog.razor.cs b/FoodsharingSiegen.Server/Dialogs/ProspectSortDialog.razor.cs new file mode 100644 index 0000000..1ea52c6 --- /dev/null +++ b/FoodsharingSiegen.Server/Dialogs/ProspectSortDialog.razor.cs @@ -0,0 +1,39 @@ +using Blazorise; +using FoodsharingSiegen.Contracts.Enums; +using FoodsharingSiegen.Server.BaseClasses; +using Microsoft.AspNetCore.Components; + +namespace FoodsharingSiegen.Server.Dialogs +{ + public partial class ProspectSortDialog : FsBase + { + [Parameter] + public ProspectSortOption CurrentSort { get; set; } = ProspectSortOption.NameAscending; + + [Parameter] + public Func? OnSortSelected { get; set; } + + public static async Task ShowAsync(IModalService modalService, ProspectSortOption currentSort, Func onSortSelected) + { + await modalService.Show("Sortieren", p => + { + p.Add(nameof(CurrentSort), currentSort); + p.Add(nameof(OnSortSelected), onSortSelected); + }, new ModalInstanceOptions + { + Size = ModalSize.Small, + }); + } + + private Color GetSortButtonColor(ProspectSortOption option) + { + return CurrentSort == option ? Color.Success : Color.Secondary; + } + + private async Task SelectAsync(ProspectSortOption option) + { + if (OnSortSelected != null) await OnSortSelected(option); + await ModalService.Hide(); + } + } +}