Add interaction removal functionality and improve ProspectContainer layout
All checks were successful
Build And Push Dev Docker Image / docker (push) Successful in 1m28s

This commit is contained in:
a.beging@eas-solutions.de
2026-04-20 14:00:21 +02:00
parent 5f5690e84d
commit c7e0bfd8da
2 changed files with 106 additions and 48 deletions

View File

@@ -1,5 +1,6 @@
@using FoodsharingSiegen.Contracts.Enums @using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper @using FoodsharingSiegen.Shared.Helper
@using System.ComponentModel
@inherits FsBase @inherits FsBase
@{ @{
@@ -11,43 +12,32 @@
<div class="@divClass"> <div class="@divClass">
<h5 class="mb-2 d-flex"> <h5 class="mb-2 d-flex">
<div class="flex-grow-1"> <div class="flex-grow-1 d-flex">
@if(string.IsNullOrWhiteSpace(Prospect?.Name)) <div>
{ @if(string.IsNullOrWhiteSpace(Prospect?.Name))
<i class="fa-solid fa-exclamation-triangle text-warning"></i>
<doublearrows></doublearrows>
<em>»Name fehlt«</em>
}
else
{
@Prospect?.Name
}
@if (Prospect?.FsId != null && Prospect.FsId != 0)
{
<small style="font-size: .9rem; margin-left: 0.5rem;">@Prospect?.FsId</small>
}
</div>
<div>
@if (CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador))
{
<i class="fa-solid fa-pen-to-square link mr-2" @onclick="EditProspectAsync" @onclick:preventDefault></i>
}
<a href="@(CurrentUser.NetworkLink)/profile/@Prospect?.FsId" target="_blank"><i class="fa-solid fa-eye"></i></a>
@if (CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador))
{
if (Prospect?.RecordState != RecordState.Archived)
{ {
<i class="fa-solid fa-box-archive link ml-2" @onclick="ArchiveProspectAsync" title="Archivieren" @onclick:preventDefault></i> <i class="fa-solid fa-exclamation-triangle text-warning"></i>
<doublearrows></doublearrows>
<em>»Name fehlt«</em>
} }
else else
{ {
<i class="fa-solid fa-recycle link ml-2" @onclick="RestoreProspectAsync" title="Wiederherstellen" @onclick:preventDefault></i> @Prospect?.Name
} }
</div>
<div style="flex-grow: 1;"></div>
@if (Prospect?.FsId != null && Prospect.FsId != 0)
{
<a href="@(CurrentUser.NetworkLink)/profile/@Prospect?.FsId" target="_blank">
<small style="font-size: .9rem;">
<i class="fa-solid fa-eye"></i> @Prospect?.FsId
</small>
</a>
} }
</div> </div>
</h5> </h5>
@@ -154,27 +144,74 @@
ButtonIconClass="fa-solid fa-check" ButtonIconClass="fa-solid fa-check"
IconClass="fa-solid fa-user-check"> IconClass="fa-solid fa-user-check">
</InteractionRow> </InteractionRow>
<tr>
<td colspan="3">
<hr style="margin: 10px 0;">
</td>
</tr>
<InteractionRow
Prospect="Prospect"
AllowInteraction="@CurrentUser.IsInGroup(UserGroup.Ambassador)"
Type="InteractionType.Complete"
AddClick="AddInteraction"
RemoveClick="@RemoveInteraction"
ButtonIconClass="fa-solid fa-check"
IconClass="fa-solid fa-flag-checkered">
</InteractionRow>
} }
</table> </table>
<div class="flex-grow-1"></div> <div class="flex-grow-1"></div>
<small class="text-center" style="margin-top: .5rem;">Zuletzt geändert: @Prospect?.Modified?.ToLocalTime()</small> <div class="text-center d-flex justify-content-center gap-2 mt-1">
<Button
Color="Color.Secondary"
Height="Height.Px(35)"
title="Bearbeiten"
Clicked="EditProspectAsync"
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
><i class="fa-solid fa-pen-to-square"></i>
</Button>
@if(StateFilter > ProspectStateFilter.OnBoarding)
{
@if(Prospect?.Complete != true)
{
<Button
Color="Color.Primary"
Height="Height.Px(35)"
title="Fertigstellen"
Clicked="@(() => AddInteraction(InteractionType.Complete))"
Visibility="@(CurrentUser.IsInGroup(UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
><i class="fa-solid fa-flag-checkered"></i>
</Button>
} else {
<Button
Color="Color.Primary"
Height="Height.Px(35)"
title="Fertigstellen rückgängig"
Clicked="@(() => AddInteraction(InteractionType.Complete))"
Visibility="@(CurrentUser.IsInGroup(UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
><i class="fa-solid fa-flag"></i>
</Button>
}
}
@if (Prospect?.RecordState != RecordState.Archived)
{
<Button
Color="Color.Danger"
Height="Height.Px(35)"
title="Archivieren"
Clicked="ArchiveProspectAsync"
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
><i class="fa-solid fa-box-archive"></i>
</Button>
}
else
{
<Button
Color="Color.Success"
Height="Height.Px(35)"
title="Wiederherstellen"
Clicked="RestoreProspectAsync"
Visibility="@(CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador) ? Visibility.Default : Visibility.Invisible)"
><i class="fa-solid fa-recycle"></i>
</Button>
}
</div>
<small class="text-center" style="margin-top: .5rem;">Geändert: @Prospect?.Modified?.ToLocalTime()</small>
</div> </div>

View File

@@ -106,6 +106,27 @@ namespace FoodsharingSiegen.Server.Controls
}); });
} }
private async Task RemoveInteraction(InteractionType type)
{
var typeName = type.Translate(AppSettings);
await ConfirmDialog.ShowAsync(ModalService, "Bestätigen", $"Alle {typeName}-Interaktionen wirklich entfernen?", async () =>
{
var interactions = Prospect?.Interactions.Where(x => x.Type == type);
var dataChanged = false;
foreach (var interaction in interactions ?? [])
{
var removeR = await ProspectService.RemoveInteraction(interaction.Id);
if (!removeR.Success) continue;
dataChanged = true;
}
if(dataChanged && OnDataChanged != null) await OnDataChanged();
});
}
#endregion #endregion
#region Private Method RestoreProspectAsync #region Private Method RestoreProspectAsync