Rename 'Deleted' state to 'Archived' and update related logic

Replaced 'Deleted' with 'Archived' across the codebase to better reflect the intent of the state. Adjusted related features, including filters, UI labels, navigation, and permissions. Introduced a 'Recent Activity' filter for improved activity tracking.
This commit is contained in:
Andre Beging
2025-04-02 08:40:38 +02:00
parent b7ba95b716
commit 6389da4bc1
10 changed files with 40 additions and 17 deletions

View File

@@ -7,6 +7,6 @@ namespace FoodsharingSiegen.Contracts.Enums
{ {
Default = 10, Default = 10,
Deleted = 20 Archived = 20
} }
} }

View File

@@ -10,6 +10,8 @@
public bool NoActivity { get; set; } public bool NoActivity { get; set; }
public bool RecentActivity { get; set; }
public bool DeletedOnly { get; set; } public bool DeletedOnly { get; set; }
} }
} }

View File

@@ -6,7 +6,7 @@
var divClass = $"{CssClass} pc-main"; var divClass = $"{CssClass} pc-main";
if (Prospect is { Complete: true }) divClass += " complete"; if (Prospect is { Complete: true }) divClass += " complete";
if (Prospect is { Warning: true }) divClass += " warning"; if (Prospect is { Warning: true }) divClass += " warning";
if (Prospect is { RecordState: RecordState.Deleted }) divClass += " deleted"; if (Prospect is { RecordState: RecordState.Archived }) divClass += " deleted";
} }
<div class="@divClass"> <div class="@divClass">
@@ -23,13 +23,13 @@
<a href="@(CurrentUser.NetworkLink)/profile/@Prospect?.FsId" target="_blank"><i class="fa-solid fa-eye"></i></a> <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 (CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador))
{ {
if (Prospect?.RecordState != RecordState.Deleted) if (Prospect?.RecordState != RecordState.Archived)
{ {
<i class="fa-solid fa-trash link ml-2" @onclick="DeleteProspectAsync" @onclick:preventDefault></i> <i class="fa-solid fa-box-archive link ml-2" @onclick="ArchiveProspectAsync" title="Archivieren" @onclick:preventDefault></i>
} }
else if(CurrentUser.IsAdmin()) else
{ {
<i class="fa-solid fa-recycle link ml-2" @onclick="RestoreProspectAsync" @onclick:preventDefault></i> <i class="fa-solid fa-recycle link ml-2" @onclick="RestoreProspectAsync" title="Wiederherstellen" @onclick:preventDefault></i>
} }
} }

View File

@@ -55,13 +55,13 @@ namespace FoodsharingSiegen.Server.Controls
/// Deletes the currently selected prospect after user confirmation. This action is irreversible and will update the record state to "Deleted". /// Deletes the currently selected prospect after user confirmation. This action is irreversible and will update the record state to "Deleted".
/// </summary> /// </summary>
/// <returns>A task that represents the asynchronous delete operation.</returns> /// <returns>A task that represents the asynchronous delete operation.</returns>
private async Task DeleteProspectAsync() private async Task ArchiveProspectAsync()
{ {
if (Prospect == null) return; if (Prospect == null) return;
await ConfirmDialog.ShowAsync(ModalService, $"⚠️ {Prospect.Name} löschen", $"Soll {Prospect.Name} mit der FS-ID {Prospect.FsId} wirklich gelöscht werden? Das kann nicht rückgängig gemacht werden!!", async () => await ConfirmDialog.ShowAsync(ModalService, $"{Prospect.Name} archivieren", $"Soll {Prospect.Name} mit der FS-ID {Prospect.FsId} wirklich ins Archiv verschoben werden?", async () =>
{ {
Prospect.RecordState = RecordState.Deleted; Prospect.RecordState = RecordState.Archived;
var updateR = await ProspectService.UpdateAsync(Prospect); var updateR = await ProspectService.UpdateAsync(Prospect);
if (updateR.Success && OnDataChanged != null) await OnDataChanged(); if (updateR.Success && OnDataChanged != null) await OnDataChanged();
}); });

View File

@@ -40,6 +40,12 @@
await FilterChanged.InvokeAsync(Filter); await FilterChanged.InvokeAsync(Filter);
} }
private async Task RecentActivityChangedAsync(bool arg)
{
Filter.RecentActivity = arg;
await FilterChanged.InvokeAsync(Filter);
}
} }
<div class="card"> <div class="card">
@@ -64,11 +70,19 @@
</div> </div>
} }
@* RECENT ACTIVITY *@
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter))
{
<div style="margin-left: 1rem;">
<Switch TValue="bool" Checked="Filter.RecentActivity" CheckedChanged="RecentActivityChangedAsync" Color="Color.Primary">Kürzlich geändert (&lt; 6 Monate)</Switch>
</div>
}
@* NO ACTIVITY *@ @* NO ACTIVITY *@
@if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter)) @if (new[] { ProspectStateFilter.All, ProspectStateFilter.OnBoarding, ProspectStateFilter.Verification }.Contains(StateFilter))
{ {
<div style="margin-left: 1rem;"> <div style="margin-left: 1rem;">
<Switch TValue="bool" Checked="Filter.NoActivity" CheckedChanged="NoActivityChangedAsync" Color="Color.Primary">Lange keine Aktivität (6 Monate)</Switch> <Switch TValue="bool" Checked="Filter.NoActivity" CheckedChanged="NoActivityChangedAsync" Color="Color.Primary">Lange keine Aktivität (&gt; 6 Monate)</Switch>
</div> </div>
} }

View File

@@ -120,7 +120,7 @@ namespace FoodsharingSiegen.Server.Data.Service
prospectsQuery = prospectsQuery.Where(x => x.Interactions.All(i => !parameter.CannotHaveInteractions.Contains(i.Type))); prospectsQuery = prospectsQuery.Where(x => x.Interactions.All(i => !parameter.CannotHaveInteractions.Contains(i.Type)));
if (!parameter.IncludeDeleted) if (!parameter.IncludeDeleted)
prospectsQuery = prospectsQuery.Where(x => x.RecordState != RecordState.Deleted); prospectsQuery = prospectsQuery.Where(x => x.RecordState != RecordState.Archived);
var prospects = await prospectsQuery.ToListAsync(); var prospects = await prospectsQuery.ToListAsync();

View File

@@ -1,11 +1,12 @@
@page "/all" @page "/all"
@page "/archive"
@using FoodsharingSiegen.Contracts.Enums @using FoodsharingSiegen.Contracts.Enums
@using FoodsharingSiegen.Shared.Helper @using FoodsharingSiegen.Shared.Helper
@inherits FsBase @inherits FsBase
<PageTitle>Alle (Admin) - @AppSettings.Terms.Title</PageTitle> <PageTitle>Archiv - @AppSettings.Terms.Title</PageTitle>
<h2>Alle (Admin)</h2> <h2>Archiv</h2>
@if (AppSettings.TestMode) @if (AppSettings.TestMode)
{ {

View File

@@ -1,5 +1,6 @@
using FoodsharingSiegen.Contracts; using FoodsharingSiegen.Contracts;
using FoodsharingSiegen.Contracts.Entity; using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Enums;
using FoodsharingSiegen.Contracts.Helper; using FoodsharingSiegen.Contracts.Helper;
using FoodsharingSiegen.Contracts.Model; using FoodsharingSiegen.Contracts.Model;
using FoodsharingSiegen.Server.Data.Service; using FoodsharingSiegen.Server.Data.Service;
@@ -45,7 +46,7 @@ namespace FoodsharingSiegen.Server.Pages
/// <inheritdoc /> /// <inheritdoc />
protected override async Task InitializeDataAsync() protected override async Task InitializeDataAsync()
{ {
if(!CurrentUser.IsAdmin()) NavigationManager.NavigateTo("/"); if(!CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador)) NavigationManager.NavigateTo("/");
// Load Filter // Load Filter
var filter = await LocalStorageService.GetItem<ProspectFilter>(StorageKeys.ProspectFilter); var filter = await LocalStorageService.GetItem<ProspectFilter>(StorageKeys.ProspectFilter);

View File

@@ -1,3 +1,4 @@
@using FoodsharingSiegen.Contracts.Enums
<nav class="d-flex flex-column h-100"> <nav class="d-flex flex-column h-100">
<div class="nav-logo"></div> <div class="nav-logo"></div>
<div class="d-flex px-3 justify-content-center text-center font-weight-bold"> <div class="d-flex px-3 justify-content-center text-center font-weight-bold">
@@ -32,13 +33,13 @@
</div> </div>
</div> </div>
@if (CurrentUser.IsAdmin()) @if (CurrentUser.IsInGroup(UserGroup.WelcomeTeam, UserGroup.Ambassador))
{ {
<hr/> <hr/>
<div class="nav-item px-3"> <div class="nav-item px-3">
<div @onclick="NavLinkClickedAsync"> <div @onclick="NavLinkClickedAsync">
<NavLink class="nav-link" href="all" Match="NavLinkMatch.All"> <NavLink class="nav-link" href="all" Match="NavLinkMatch.All">
<span class="fas fa-user-shield mr-2" aria-hidden="true" style="font-size: 1.4em;"></span> Alle (Admin) <span class="fas fa-box-archive mr-2" aria-hidden="true" style="font-size: 1.4em;"></span> Alle / Archiv
</NavLink> </NavLink>
</div> </div>
</div> </div>

View File

@@ -43,12 +43,16 @@ namespace FoodsharingSiegen.Shared.Helper
// Show only deleted prospects // Show only deleted prospects
if (filter.DeletedOnly) if (filter.DeletedOnly)
filterListQ = filterListQ.Where(x => x.RecordState == RecordState.Deleted); filterListQ = filterListQ.Where(x => x.RecordState == RecordState.Archived);
// No Activity Filter // No Activity Filter
if (filter.NoActivity) if (filter.NoActivity)
filterListQ = filterListQ.Where(x => DateTime.Now - x.Modified > TimeSpan.FromDays(180)); filterListQ = filterListQ.Where(x => DateTime.Now - x.Modified > TimeSpan.FromDays(180));
// Recent Activity Filter
if (filter.RecentActivity)
filterListQ = filterListQ.Where(x => DateTime.Now - x.Modified < TimeSpan.FromDays(180));
return filterListQ.ToList(); return filterListQ.ToList();
} }