Refactor interaction handling with utility for translations
Introduced `TermHelper.Translate` to centralize string mappings for `InteractionType`, reducing duplication across components. Updated related code to leverage this utility and streamline interaction row implementation by removing the `Caption` parameter. Minor UI adjustments were also made to align button positioning and styling.
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
@using FoodsharingSiegen.Contracts.Entity
|
||||
@using FoodsharingSiegen.Shared.Helper
|
||||
|
||||
@inherits FsBase
|
||||
|
||||
@{
|
||||
var rowClass = "";
|
||||
@@ -11,7 +14,7 @@
|
||||
<th class="text-center align-top pr-2">
|
||||
<i class="@IconClass"></i>
|
||||
</th>
|
||||
<th class="pr-2 align-top" style="white-space: nowrap;">@Caption:</th>
|
||||
<th class="pr-2 align-top" style="white-space: nowrap;">@Type.Translate(AppSettings):</th>
|
||||
<td class="align-top d-flex flex-column">
|
||||
@if (Interactions.Count > 0)
|
||||
{
|
||||
@@ -39,7 +42,7 @@
|
||||
{
|
||||
if (Multiple) ButtonIconClass = "fa-solid fa-plus";
|
||||
<div class="m-auto">
|
||||
<Button Size="Size.Small" Clicked="AddClick"><i class="@ButtonIconClass" style="color: #64ae24;"></i></Button>
|
||||
<Button Size="Size.Small" Clicked="@(async () => { if (AddClick != null) await AddClick(Type); })"><i class="@ButtonIconClass" style="color: #64ae24;"></i></Button>
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
|
||||
@@ -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
|
||||
/// <summary>
|
||||
/// The interaction row class (a. beging, 31.05.2022)
|
||||
/// </summary>
|
||||
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)
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback AddClick { get; set; }
|
||||
public Func<InteractionType, Task>? AddClick { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the caption (ab)
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string? Caption { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the icon class (ab)
|
||||
/// </summary>
|
||||
@@ -87,7 +82,7 @@ namespace FoodsharingSiegen.Server.Controls
|
||||
/// <summary>
|
||||
/// Gets the value of the interactions (ab)
|
||||
/// </summary>
|
||||
private List<Interaction> Interactions => Prospect?.Interactions?.Where(x => x.Type == Type).ToList() ?? new List<Interaction>();
|
||||
private List<Interaction> Interactions => Prospect?.Interactions.Where(x => x.Type == Type).ToList() ?? [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the not needed (ab)
|
||||
|
||||
@@ -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">
|
||||
</InteractionRow>
|
||||
@@ -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">
|
||||
</InteractionRow>
|
||||
@@ -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">
|
||||
</InteractionRow>
|
||||
@@ -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">
|
||||
</InteractionRow>
|
||||
@@ -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">
|
||||
</InteractionRow>
|
||||
@@ -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">
|
||||
</InteractionRow>
|
||||
@@ -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">
|
||||
</InteractionRow>
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user