diff --git a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor index 9d1a366..757303e 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor +++ b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor @@ -73,6 +73,12 @@ IconClass="fa-solid fa-handshake-simple"> + + +
+ + + @if (!AppSettings.DisableStepIn) { FilterChanged { get; set; } - - [Parameter] public ProspectStateFilter StateFilter { get; set; } - - - private async Task WithoutStepInBriefingChangedAsync(bool arg) - { - Filter.WithoutStepInBriefing = arg; - await FilterChanged.InvokeAsync(Filter); - } - - private async Task TextChanged(string arg) - { - Filter.Text = arg; - await FilterChanged.InvokeAsync(Filter); - } - - private async Task WithoutIdCheckChangedAsync(bool arg) - { - Filter.WithoutIdCheck = arg; - await FilterChanged.InvokeAsync(Filter); - } - - private async Task NoActivityChangedAsync(bool arg) - { - Filter.NoActivity = arg; - await FilterChanged.InvokeAsync(Filter); - } - - private async Task DeletedOnlyChangedAsync(bool arg) - { - Filter.DeletedOnly = arg; - await FilterChanged.InvokeAsync(Filter); - } - - private async Task RecentActivityChangedAsync(bool arg) - { - Filter.RecentActivity = arg; - await FilterChanged.InvokeAsync(Filter); - } - -} - -
-
- Suchfilter -
-
- - @if (!AppSettings.DisableStepIn) - { - @* WITHOUT STEP IN BRIEFING *@ - @if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Completed }.Contains(StateFilter)) - { -
- Ohne @AppSettings.Terms.StepInName -
- } - } - - @* WITHOUT ID CHECK *@ - @if (new[] { ProspectStateFilter.All, ProspectStateFilter.Verification, ProspectStateFilter.Completed }.Contains(StateFilter)) - { -
- Perso noch nicht geprüft -
- } - - @* RECENT ACTIVITY *@ - @if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter)) - { -
- Kürzlich geändert (< 6 Monate) -
- } - - @* NO ACTIVITY *@ - @if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter)) - { -
- Lange keine Aktivität (> 6 Monate) -
- } - - @* DELETED ONLY *@ - @if (new[] { ProspectStateFilter.All }.Contains(StateFilter)) - { -
- Gelöschte -
- } - - -
-
\ No newline at end of file diff --git a/FoodsharingSiegen.Server/Controls/ProspectGrid.razor b/FoodsharingSiegen.Server/Controls/ProspectGrid.razor index 328f4fa..815dbb3 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectGrid.razor +++ b/FoodsharingSiegen.Server/Controls/ProspectGrid.razor @@ -8,7 +8,7 @@ [Parameter] public Func? OnDataChanged { get; set; } } -
@(Prospects?.Count ?? 0) Einträge
+
@(Prospects?.Count ?? 0) Ergebnisse
@if (Prospects?.Any() == true) { diff --git a/FoodsharingSiegen.Server/Controls/ProspectSortControl.razor b/FoodsharingSiegen.Server/Controls/ProspectSortControl.razor index 398e8c8..1ec021d 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectSortControl.razor +++ b/FoodsharingSiegen.Server/Controls/ProspectSortControl.razor @@ -1,17 +1,52 @@ @using FoodsharingSiegen.Contracts.Enums +@inherits FoodsharingSiegen.Server.BaseClasses.FsBase - + -
+ + +
+ +
+ +
@if (HasCustomSort) { - @CurrentSortText + @CurrentSortText + } + + @if (Filter.WithoutStepInBriefing) + { + Ohne @AppSettings.Terms.StepInName + } + @if (Filter.WithoutIdCheck) + { + Perso noch nicht geprüft + } + @if (Filter.RecentActivity) + { + Kürzlich geändert + } + @if (Filter.NoActivity) + { + Lange keine Aktivität + } + @if (Filter.DeletedOnly) + { + Gelöschte }
\ No newline at end of file diff --git a/FoodsharingSiegen.Server/Controls/ProspectSortControl.razor.cs b/FoodsharingSiegen.Server/Controls/ProspectSortControl.razor.cs index ec79afa..72acb4e 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectSortControl.razor.cs +++ b/FoodsharingSiegen.Server/Controls/ProspectSortControl.razor.cs @@ -1,6 +1,7 @@ using Blazorise; using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Enums; +using FoodsharingSiegen.Contracts.Model; using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Dialogs; using FoodsharingSiegen.Server.Service; @@ -26,6 +27,10 @@ public partial class ProspectSortControl [Parameter] public string? StorageKey { get; set; } + [Parameter] public ProspectFilter Filter { get; set; } = new(); + [Parameter] public EventCallback FilterChanged { get; set; } + [Parameter] public ProspectStateFilter StateFilter { get; set; } = ProspectStateFilter.All; + protected override async Task OnInitializedAsync() { if (!string.IsNullOrEmpty(StorageKey)) @@ -48,6 +53,35 @@ public partial class ProspectSortControl }); } + private async Task OpenFilterDialogAsync() + { + await ProspectFilterDialog.ShowAsync(ModalService, Filter, StateFilter, async (f) => + { + Filter = f; + await FilterChanged.InvokeAsync(Filter); + await InvokeAsync(StateHasChanged); + }); + } + + private async Task TextChangedAsync(string text) + { + Filter.Text = text; + await FilterChanged.InvokeAsync(Filter); + } + + private async Task DisableFilterAsync(string filterPropName) + { + switch (filterPropName) + { + case nameof(Filter.WithoutStepInBriefing): Filter.WithoutStepInBriefing = false; break; + case nameof(Filter.WithoutIdCheck): Filter.WithoutIdCheck = false; break; + case nameof(Filter.RecentActivity): Filter.RecentActivity = false; break; + case nameof(Filter.NoActivity): Filter.NoActivity = false; break; + case nameof(Filter.DeletedOnly): Filter.DeletedOnly = false; break; + } + await FilterChanged.InvokeAsync(Filter); + } + private bool HasCustomSort => CurrentSort != ProspectSortOption.NameAscending; private string CurrentSortText => CurrentSort switch diff --git a/FoodsharingSiegen.Server/Dialogs/ProspectFilterDialog.razor b/FoodsharingSiegen.Server/Dialogs/ProspectFilterDialog.razor new file mode 100644 index 0000000..1c1ca68 --- /dev/null +++ b/FoodsharingSiegen.Server/Dialogs/ProspectFilterDialog.razor @@ -0,0 +1,49 @@ +@inherits FsBase +@using FoodsharingSiegen.Contracts.Enums + +
+ @if (!AppSettings.DisableStepIn && new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Completed }.Contains(StateFilter)) + { +
+ + Ohne @AppSettings.Terms.StepInName + +
+ } + + @if (new[] { ProspectStateFilter.All, ProspectStateFilter.Verification, ProspectStateFilter.Completed }.Contains(StateFilter)) + { +
+ + Perso noch nicht geprüft + +
+ } + + @if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter)) + { +
+ + Kürzlich geändert (< 6 Monate) + +
+
+ + Lange keine Aktivität (> 6 Monate) + +
+ } + + @if (StateFilter == ProspectStateFilter.All) + { +
+ + Gelöschte + +
+ } + +
+ +
+
diff --git a/FoodsharingSiegen.Server/Dialogs/ProspectFilterDialog.razor.cs b/FoodsharingSiegen.Server/Dialogs/ProspectFilterDialog.razor.cs new file mode 100644 index 0000000..d8518d4 --- /dev/null +++ b/FoodsharingSiegen.Server/Dialogs/ProspectFilterDialog.razor.cs @@ -0,0 +1,51 @@ +using Blazorise; +using FoodsharingSiegen.Contracts.Enums; +using FoodsharingSiegen.Contracts.Model; +using FoodsharingSiegen.Server.BaseClasses; +using Microsoft.AspNetCore.Components; + +namespace FoodsharingSiegen.Server.Dialogs +{ + public partial class ProspectFilterDialog : FsBase + { + [Parameter] public ProspectFilter CurrentFilter { get; set; } = new(); + [Parameter] public ProspectStateFilter StateFilter { get; set; } = ProspectStateFilter.All; + [Parameter] public Func? OnFilterApplied { get; set; } + + public ProspectFilter ModalFilter { get; set; } = new(); + + protected override void OnInitialized() + { + // Clone the filter so changes are not immediately mapped to the parent until "Anwenden" is pressed + ModalFilter = new ProspectFilter + { + Text = CurrentFilter.Text, + WithoutStepInBriefing = CurrentFilter.WithoutStepInBriefing, + WithoutIdCheck = CurrentFilter.WithoutIdCheck, + NoActivity = CurrentFilter.NoActivity, + RecentActivity = CurrentFilter.RecentActivity, + DeletedOnly = CurrentFilter.DeletedOnly + }; + base.OnInitialized(); + } + + public static async Task ShowAsync(IModalService modalService, ProspectFilter currentFilter, ProspectStateFilter stateFilter, Func onFilterApplied) + { + await modalService.Show("Filtern", p => + { + p.Add(nameof(CurrentFilter), currentFilter); + p.Add(nameof(StateFilter), stateFilter); + p.Add(nameof(OnFilterApplied), onFilterApplied); + }, new ModalInstanceOptions + { + Size = ModalSize.Small, + }); + } + + private async Task ApplyAsync() + { + if (OnFilterApplied != null) await OnFilterApplied(ModalFilter); + await ModalService.Hide(); + } + } +} \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Pages/Prospects.razor b/FoodsharingSiegen.Server/Pages/Prospects.razor index d4a1ad3..de5ae97 100644 --- a/FoodsharingSiegen.Server/Pages/Prospects.razor +++ b/FoodsharingSiegen.Server/Pages/Prospects.razor @@ -25,17 +25,16 @@ Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)" > +| - + @{ var filterList = ProspectList.ApplyFilter(Filter); var sortList = filterList.ApplySort(CurrentSort); } -
- -
+ TESTMODUS! Änderungen werden wieder gelöscht.
} - + @{ var filterList = ProspectList.ApplyFilter(Filter); var sortList = filterList.ApplySort(CurrentSort); } -
- -
TESTMODUS! Änderungen werden wieder gelöscht. } - + @{ var filterList = ProspectList.ApplyFilter(Filter); var sortList = filterList.ApplySort(CurrentSort); } -
- -
TESTMODUS! Änderungen werden wieder gelöscht. } - + @{ var filterList = ProspectList.ApplyFilter(Filter); var sortList = filterList.ApplySort(CurrentSort); } -
- -
+