Refactor prospect filtering and sorting components; remove obsolete ProspectFilterControl and enhance ProspectSortControl with filtering capabilities.
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m31s
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m31s
This commit is contained in:
49
FoodsharingSiegen.Server/Dialogs/ProspectFilterDialog.razor
Normal file
49
FoodsharingSiegen.Server/Dialogs/ProspectFilterDialog.razor
Normal file
@@ -0,0 +1,49 @@
|
||||
@inherits FsBase
|
||||
@using FoodsharingSiegen.Contracts.Enums
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
@if (!AppSettings.DisableStepIn && new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Completed }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.WithoutStepInBriefing" CheckedChanged="(v) => { ModalFilter.WithoutStepInBriefing = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Ohne @AppSettings.Terms.StepInName
|
||||
</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.Verification, ProspectStateFilter.Completed }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.WithoutIdCheck" CheckedChanged="(v) => { ModalFilter.WithoutIdCheck = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Perso noch nicht geprüft
|
||||
</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter))
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.RecentActivity" CheckedChanged="(v) => { ModalFilter.RecentActivity = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Kürzlich geändert (< 6 Monate)
|
||||
</Switch>
|
||||
</div>
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.NoActivity" CheckedChanged="(v) => { ModalFilter.NoActivity = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Lange keine Aktivität (> 6 Monate)
|
||||
</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (StateFilter == ProspectStateFilter.All)
|
||||
{
|
||||
<div style="margin-left: 1rem;">
|
||||
<Switch TValue="bool" Checked="ModalFilter.DeletedOnly" CheckedChanged="(v) => { ModalFilter.DeletedOnly = v; StateHasChanged(); }" Color="Color.Primary">
|
||||
Gelöschte
|
||||
</Switch>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="d-flex justify-content-end mt-3">
|
||||
<Button Color="Color.Primary" Clicked="ApplyAsync" Block="true">Anwenden</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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<ProspectFilter, Task>? 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<ProspectFilter, Task> onFilterApplied)
|
||||
{
|
||||
await modalService.Show<ProspectFilterDialog>("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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user