diff --git a/FoodsharingSiegen.Server/Controls/InteractionRow.razor b/FoodsharingSiegen.Server/Controls/InteractionRow.razor index f4414e5..e4a0183 100644 --- a/FoodsharingSiegen.Server/Controls/InteractionRow.razor +++ b/FoodsharingSiegen.Server/Controls/InteractionRow.razor @@ -1,4 +1,7 @@ @using FoodsharingSiegen.Contracts.Entity +@using FoodsharingSiegen.Shared.Helper + +@inherits FsBase @{ var rowClass = ""; @@ -11,7 +14,7 @@ - @Caption: + @Type.Translate(AppSettings): @if (Interactions.Count > 0) { @@ -39,7 +42,7 @@ { if (Multiple) ButtonIconClass = "fa-solid fa-plus";
- +
} diff --git a/FoodsharingSiegen.Server/Controls/InteractionRow.razor.cs b/FoodsharingSiegen.Server/Controls/InteractionRow.razor.cs index ecd7488..b7bac36 100644 --- a/FoodsharingSiegen.Server/Controls/InteractionRow.razor.cs +++ b/FoodsharingSiegen.Server/Controls/InteractionRow.razor.cs @@ -1,4 +1,5 @@ using FoodsharingSiegen.Contracts.Entity; +using FoodsharingSiegen.Server.BaseClasses; using Microsoft.AspNetCore.Components; namespace FoodsharingSiegen.Server.Controls @@ -6,7 +7,7 @@ namespace FoodsharingSiegen.Server.Controls /// /// The interaction row class (a. beging, 31.05.2022) /// - public partial class InteractionRow + public partial class InteractionRow : FsBase { #region Parameters @@ -14,7 +15,7 @@ namespace FoodsharingSiegen.Server.Controls /// Gets or sets the value of the add click (ab) /// [Parameter] - public EventCallback AddClick { get; set; } + public Func? AddClick { get; set; } /// /// Gets or sets the value of the allow add interaction (ab) @@ -28,12 +29,6 @@ namespace FoodsharingSiegen.Server.Controls [Parameter] public string? ButtonIconClass { get; set; } - /// - /// Gets or sets the value of the caption (ab) - /// - [Parameter] - public string? Caption { get; set; } - /// /// Gets or sets the value of the icon class (ab) /// @@ -87,7 +82,7 @@ namespace FoodsharingSiegen.Server.Controls /// /// Gets the value of the interactions (ab) /// - private List Interactions => Prospect?.Interactions?.Where(x => x.Type == Type).ToList() ?? new List(); + private List Interactions => Prospect?.Interactions.Where(x => x.Type == Type).ToList() ?? []; /// /// Gets the value of the not needed (ab) diff --git a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor index 8ec650e..d0f27dc 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor +++ b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor @@ -1,4 +1,5 @@ -@inherits FsBase +@using FoodsharingSiegen.Shared.Helper +@inherits FsBase @{ var divClass = $"{CssClass} pc-main"; @@ -35,9 +36,8 @@ Prospect="Prospect" Type="InteractionType.Welcome" AllowInteraction="@(StateFilter == ProspectStateFilter.OnBoarding && CurrentUser.IsInGroup(UserGroup.WelcomeTeam))" - AddClick="() => AddInteraction(InteractionType.Welcome)" + AddClick="AddInteraction" RemoveClick="@RemoveInteraction" - Caption="Begrüßung" ButtonIconClass="fa-solid fa-check" IconClass="fa-solid fa-handshake-simple"> @@ -46,9 +46,8 @@ Prospect="Prospect" Type="InteractionType.StepInBriefing" AllowInteraction="@(StateFilter == ProspectStateFilter.OnBoarding && CurrentUser.IsInGroup(UserGroup.WelcomeTeam))" - AddClick="() => AddInteraction(InteractionType.StepInBriefing)" + AddClick="AddInteraction" RemoveClick="@RemoveInteraction" - Caption="@AppSettings.Terms.StepInName" ButtonIconClass="fa-solid fa-check" IconClass="fa-solid fa-graduation-cap"> @@ -57,9 +56,8 @@ Prospect="Prospect" Type="InteractionType.EinAb" AllowInteraction="@(StateFilter == ProspectStateFilter.OnBoarding && CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.StoreManager, UserGroup.Ambassador))" - AddClick="() => AddInteraction(InteractionType.EinAb)" + AddClick="AddInteraction" RemoveClick="@RemoveInteraction" - Caption="Einführungen" Multiple="true" Minimum="3" ButtonIconClass="fa-solid fa-plus" @@ -76,9 +74,8 @@ Prospect="Prospect" Type="InteractionType.ReleasedForVerification" AllowInteraction="@(StateFilter is ProspectStateFilter.OnBoarding or ProspectStateFilter.Verification && CurrentUser.IsInGroup(UserGroup.WelcomeTeam))" - AddClick="() => AddInteraction(InteractionType.ReleasedForVerification)" + AddClick="AddInteraction" RemoveClick="@RemoveInteraction" - Caption="Freigabe zur Verifizierung" ButtonIconClass="fa-solid fa-check" IconClass="fa-solid fa-id-card"> @@ -89,9 +86,8 @@ Prospect="Prospect" Type="InteractionType.IdCheck" AllowInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)" - AddClick="() => AddInteraction(InteractionType.IdCheck)" + AddClick="AddInteraction" RemoveClick="@RemoveInteraction" - Caption="Perso checken" ButtonIconClass="fa-solid fa-check" IconClass="fa-solid fa-magnifying-glass"> @@ -103,9 +99,8 @@ Prospect="Prospect" Type="InteractionType.PrintPass" AllowInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)" - AddClick="() => AddInteraction(InteractionType.PrintPass)" + AddClick="AddInteraction" RemoveClick="@RemoveInteraction" - Caption="FS-Ausweis (print)" ButtonIconClass="fa-solid fa-check" IconClass="fa-solid fa-id-card"> @@ -114,9 +109,8 @@ Prospect="Prospect" AllowInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)" Type="InteractionType.Verify" - AddClick="() => AddInteraction(InteractionType.Verify)" + AddClick="AddInteraction" RemoveClick="@RemoveInteraction" - Caption="Verifizieren" ButtonIconClass="fa-solid fa-check" IconClass="fa-solid fa-user-check"> @@ -131,9 +125,8 @@ Prospect="Prospect" AllowInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)" Type="InteractionType.Complete" - AddClick="() => AddInteraction(InteractionType.Complete)" + AddClick="AddInteraction" RemoveClick="@RemoveInteraction" - Caption="Fertig" ButtonIconClass="fa-solid fa-check" IconClass="fa-solid fa-flag-checkered"> diff --git a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.cs b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.cs index 01178be..93764a4 100644 --- a/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.cs +++ b/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.cs @@ -1,6 +1,7 @@ using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Dialogs; +using FoodsharingSiegen.Shared.Helper; using Microsoft.AspNetCore.Components; namespace FoodsharingSiegen.Server.Controls @@ -20,19 +21,7 @@ namespace FoodsharingSiegen.Server.Controls { if (Prospect != null && OnDataChanged != null) { - 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" - }; + var headerText = $"{type.Translate(AppSettings)} eintragen"; await InteractionDialog.ShowAsync(ModalService, new(type, Prospect.Id, headerText, OnDataChanged)); } @@ -57,7 +46,10 @@ namespace FoodsharingSiegen.Server.Controls private async Task RemoveInteraction(Guid arg) { - var confirm = await Message.Confirm("Interaktion wirklich löschen?", "Bestätigen", o => + var type = Prospect?.Interactions.FirstOrDefault(x => x.Id == arg)?.Type; + var typeName = type != null ? type.Value.Translate(AppSettings) : "Interaktion"; + + var confirm = await Message.Confirm($"{typeName} wirklich entfernen?", "Bestätigen", o => { o.ConfirmButtonText = "Ja, wirklich!"; o.CancelButtonText = "Abbrechen"; diff --git a/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor b/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor index 9c0aa3e..cb01182 100644 --- a/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor +++ b/FoodsharingSiegen.Server/Dialogs/EditProspectDialog.razor @@ -25,4 +25,6 @@ Achtung! - \ No newline at end of file +
+ +
diff --git a/FoodsharingSiegen.Server/Dialogs/InteractionDialog.razor b/FoodsharingSiegen.Server/Dialogs/InteractionDialog.razor index e043383..c5f129a 100644 --- a/FoodsharingSiegen.Server/Dialogs/InteractionDialog.razor +++ b/FoodsharingSiegen.Server/Dialogs/InteractionDialog.razor @@ -33,5 +33,7 @@ } - - \ No newline at end of file +
+ + +
diff --git a/FoodsharingSiegen.Shared/Helper/TermHelper.cs b/FoodsharingSiegen.Shared/Helper/TermHelper.cs new file mode 100644 index 0000000..dab939b --- /dev/null +++ b/FoodsharingSiegen.Shared/Helper/TermHelper.cs @@ -0,0 +1,38 @@ +#nullable enable + +using FoodsharingSiegen.Contracts.Entity; +using FoodsharingSiegen.Contracts.Model; + +namespace FoodsharingSiegen.Shared.Helper +{ + public static class TermHelper + { + #region Public Method Translate + + /// + /// Translates an instance into a corresponding string representation, + /// using the provided application settings if necessary. + /// + /// The interaction type to translate. + /// The application settings used for custom translations. + /// A string representation of the specified interaction type. + public static string Translate(this InteractionType type, AppSettings appSettings) + { + return type switch + { + InteractionType.EinAb => "Einführung", + InteractionType.Welcome => "Begrüßung", + InteractionType.IdCheck => "Perso prüfen", + InteractionType.PrintPass => "FS-Ausweis (Print)", + InteractionType.PdfPass => "FS-Ausweis (PDF)", + InteractionType.Verify => "Verifizieren", + InteractionType.Complete => "Fertig", + InteractionType.StepInBriefing => appSettings.Terms.StepInName ?? "StepIn", + InteractionType.ReleasedForVerification => "Freigabe zur Verifizierung", + _ => type.ToString() + }; + } + + #endregion + } +} \ No newline at end of file