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(); + } + } +}