diff --git a/FoodsharingSiegen.Contracts/Model/ProspectFilter.cs b/FoodsharingSiegen.Contracts/Model/ProspectFilter.cs index c3a5dc7..6b76034 100644 --- a/FoodsharingSiegen.Contracts/Model/ProspectFilter.cs +++ b/FoodsharingSiegen.Contracts/Model/ProspectFilter.cs @@ -5,5 +5,9 @@ public string? Text { get; set; } public bool WithoutStepInBriefing { get; set; } + + public bool WithoutIdCheck { get; set; } + + public bool NoActivity { get; set; } } } \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.cs b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.cs index 7921c9b..01178be 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.cs +++ b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.cs @@ -19,7 +19,24 @@ namespace FoodsharingSiegen.Server.Controls private async Task AddInteraction(InteractionType type) { if (Prospect != null && OnDataChanged != null) - await InteractionDialog.ShowAsync(ModalService, OnDataChanged, type, Prospect.Id); + { + var headerText = type switch + { + InteractionType.EinAb => "Einführung eintragen", + InteractionType.Welcome => "Begrüßung eintragen", + InteractionType.IdCheck => "Ausweisprüfung eintragen", + InteractionType.PrintPass => "FS-Ausweis (Print)", + InteractionType.PdfPass => "FS-Ausweis (PDF)", + InteractionType.Verify => "Verifizierung eintragen", + InteractionType.Complete => "Als fertig markieren", + InteractionType.StepInBriefing => $"{AppSettings.Terms.StepInName} absolviert", + InteractionType.ReleasedForVerification => "Zur Verifizierung freigegeben", + _ => "Neuer Eintrag" + }; + + await InteractionDialog.ShowAsync(ModalService, new(type, Prospect.Id, headerText, OnDataChanged)); + } + } private List GetTyped(InteractionType type) diff --git a/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor b/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor index eda0e7e..7d7e47d 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor +++ b/FoodsharingSiegen.Server/Controls/ProspectFilterControl.razor @@ -2,11 +2,9 @@ @inherits FsBase @code { - [Parameter] - public ProspectFilter Filter { get; set; } = new(); + [Parameter] public ProspectFilter Filter { get; set; } = new(); - [Parameter] - public EventCallback FilterChanged { get; set; } + [Parameter] public EventCallback FilterChanged { get; set; } [Parameter] public ProspectStateFilter StateFilter { get; set; } @@ -23,6 +21,18 @@ 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); + } + }
@@ -36,6 +46,18 @@ Ohne @AppSettings.Terms.StepInName
} + @if (StateFilter == ProspectStateFilter.Verification) + { +
+ Perso noch nicht geprüft +
+ } + @if (StateFilter is ProspectStateFilter.OnBoarding or ProspectStateFilter.Verification) + { +
+ Lange keine Aktivität (6 Monate) +
+ } \ No newline at end of file diff --git a/FoodsharingSiegen.Server/Dialogs/InteractionDialog.razor.cs b/FoodsharingSiegen.Server/Dialogs/InteractionDialog.razor.cs index 130eafc..e157ad0 100644 --- a/FoodsharingSiegen.Server/Dialogs/InteractionDialog.razor.cs +++ b/FoodsharingSiegen.Server/Dialogs/InteractionDialog.razor.cs @@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Components; namespace FoodsharingSiegen.Server.Dialogs { + public record InteractionDialogParameter(InteractionType Type, Guid ProspectId, string HeaderText, Func OnSuccess); + public partial class InteractionDialog : FsBase { #region Dependencies @@ -43,40 +45,16 @@ namespace FoodsharingSiegen.Server.Dialogs #region Public Method ShowAsync /// - /// Displays a modal dialog for adding an interaction with configurable settings based on the interaction type and associated prospect ID. + /// Displays the InteractionDialog modal with the specified parameters. /// - /// - /// The modal service used to display the modal dialog. - /// - /// - /// Callback to be invoked upon successful addition of an interaction - /// - /// - /// The type of interaction to be added. - /// - /// - /// The unique identifier of the prospect associated with the interaction. - /// + /// The modal service used to display the dialog. + /// The parameters required for the dialog, including type, prospect ID, header text, and success callback. /// - /// A task representing the asynchronous operation of showing the modal dialog. + /// A task representing the asynchronous operation. /// - public static async Task ShowAsync(IModalService modalService, Func onSuccess, InteractionType type, Guid prospectId) + public static async Task ShowAsync(IModalService modalService, InteractionDialogParameter parameter) { - var headerText = type switch - { - InteractionType.EinAb => "Einführung eintragen", - InteractionType.Welcome => "Begrüßung eintragen", - InteractionType.IdCheck => "Ausweisprüfung eintragen", - InteractionType.PrintPass => "FS-Ausweis (Print)", - InteractionType.PdfPass => "FS-Ausweis (PDF)", - InteractionType.Verify => "Verifizierung eintragen", - InteractionType.Complete => "Als fertig markieren", - InteractionType.StepInBriefing => $"Neulingstreffen absolviert", - InteractionType.ReleasedForVerification => "Zur Verifizierung freigegeben", - _ => "Neuer Eintrag" - }; - - var showInfo = type switch + var showInfo = parameter.Type switch { InteractionType.EinAb => true, InteractionType.Complete => true, @@ -87,21 +65,21 @@ namespace FoodsharingSiegen.Server.Dialogs _ => false }; - var infoName = type switch + var infoName = parameter.Type switch { InteractionType.EinAb => "Welcher Betrieb?", InteractionType.ReleasedForVerification => "Hinweis", _ => "Kommentar" }; - var showAlert = type switch + var showAlert = parameter.Type switch { InteractionType.EinAb => true, InteractionType.IdCheck => true, _ => false }; - var showNotNeeded = type switch + var showNotNeeded = parameter.Type switch { InteractionType.PrintPass => true, InteractionType.PdfPass => true, @@ -110,19 +88,19 @@ namespace FoodsharingSiegen.Server.Dialogs var interaction = new Interaction { - Type = type, + Type = parameter.Type, Date = DateTime.UtcNow, - ProspectID = prospectId + ProspectID = parameter.ProspectId }; - await modalService.Show(headerText, parameter => + await modalService.Show(parameter.HeaderText, p => { - parameter.Add(nameof(Interaction), interaction); - parameter.Add(nameof(ShowInfo), showInfo); - parameter.Add(nameof(InfoName), infoName); - parameter.Add(nameof(ShowAlert), showAlert); - parameter.Add(nameof(ShowNotNeeded), showNotNeeded); - parameter.Add(nameof(OnSuccess), onSuccess); + p.Add(nameof(Interaction), interaction); + p.Add(nameof(ShowInfo), showInfo); + p.Add(nameof(InfoName), infoName); + p.Add(nameof(ShowAlert), showAlert); + p.Add(nameof(ShowNotNeeded), showNotNeeded); + p.Add(nameof(OnSuccess), parameter.OnSuccess); }); } diff --git a/FoodsharingSiegen.Shared/Helper/FilterHelper.cs b/FoodsharingSiegen.Shared/Helper/FilterHelper.cs index 22c57a0..78b8974 100644 --- a/FoodsharingSiegen.Shared/Helper/FilterHelper.cs +++ b/FoodsharingSiegen.Shared/Helper/FilterHelper.cs @@ -1,4 +1,5 @@ -using FoodsharingSiegen.Contracts.Entity; +using System.Linq.Expressions; +using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Model; namespace FoodsharingSiegen.Shared.Helper @@ -33,6 +34,18 @@ namespace FoodsharingSiegen.Shared.Helper if (filter.WithoutStepInBriefing) filterListQ = filterListQ.Where(x => x.Interactions.All(i => i.Type != InteractionType.StepInBriefing)); + + if (filter.WithoutIdCheck) + filterListQ = filterListQ.Where(x => x.Interactions.All(i => i.Type != InteractionType.IdCheck)); + + if (filter.NoActivity) + { + var days = 180; // Half year + Func q1 = x => x.Interactions.Any() && x.Interactions.All(i => DateTime.Now - i.Date > TimeSpan.FromDays(days)); + Func q2 = x => DateTime.Now - x.Created > TimeSpan.FromDays(days); + + filterListQ = filterListQ.Where(x => q1(x) && q2(x)); + } return filterListQ.ToList(); }