Store Filter between pages
This commit is contained in:
@@ -5,9 +5,18 @@ namespace FoodsharingSiegen.Contracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class StorageKeys
|
public static class StorageKeys
|
||||||
{
|
{
|
||||||
|
#region Constants
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The token key
|
/// Represents the storage key used for prospect filtering preferences.
|
||||||
|
/// </summary>
|
||||||
|
public const string ProspectFilter = "ProspectFilter";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The token key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string TokenKey = "_token";
|
public const string TokenKey = "_token";
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@ using FoodsharingSiegen.Contracts.Entity;
|
|||||||
using FoodsharingSiegen.Contracts.Model;
|
using FoodsharingSiegen.Contracts.Model;
|
||||||
using FoodsharingSiegen.Server.Auth;
|
using FoodsharingSiegen.Server.Auth;
|
||||||
using FoodsharingSiegen.Server.Data.Service;
|
using FoodsharingSiegen.Server.Data.Service;
|
||||||
|
using FoodsharingSiegen.Server.Service;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
@@ -31,6 +32,12 @@ namespace FoodsharingSiegen.Server.BaseClasses
|
|||||||
[Inject]
|
[Inject]
|
||||||
protected AuthService AuthService { get; set; } = null!;
|
protected AuthService AuthService { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the service that interacts with the browser's local storage.
|
||||||
|
/// </summary>
|
||||||
|
[Inject]
|
||||||
|
protected LocalStorageService LocalStorageService { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the modal service for handling modals within the application
|
/// Gets or sets the modal service for handling modals within the application
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<ProspectFilterControl @bind-Filter="Filter" StateFilter="ProspectStateFilter.OnBoarding"></ProspectFilterControl>
|
<ProspectFilterControl Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.OnBoarding"></ProspectFilterControl>
|
||||||
<hr />
|
<hr />
|
||||||
<ProspectGrid
|
<ProspectGrid
|
||||||
Prospects="filterList"
|
Prospects="filterList"
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
using FoodsharingSiegen.Contracts;
|
||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
using FoodsharingSiegen.Contracts.Enums;
|
using FoodsharingSiegen.Contracts.Enums;
|
||||||
using FoodsharingSiegen.Contracts.Model;
|
using FoodsharingSiegen.Contracts.Model;
|
||||||
using FoodsharingSiegen.Server.Data.Service;
|
using FoodsharingSiegen.Server.Data.Service;
|
||||||
using FoodsharingSiegen.Server.Dialogs;
|
using FoodsharingSiegen.Server.Dialogs;
|
||||||
|
using FoodsharingSiegen.Server.Service;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
namespace FoodsharingSiegen.Server.Pages
|
namespace FoodsharingSiegen.Server.Pages
|
||||||
@@ -14,17 +16,14 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
{
|
{
|
||||||
#region Dependencies
|
#region Dependencies
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the value of the prospect service (ab)
|
|
||||||
/// </summary>
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public ProspectService ProspectService { get; set; } = null!;
|
private ProspectService ProspectService { get; set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the value of the user service (ab)
|
/// Gets or sets the value of the user service (ab)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Inject]
|
[Inject]
|
||||||
public UserService UserService { get; set; } = null!;
|
private UserService UserService { get; set; } = null!;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -44,6 +43,9 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override async Task InitializeDataAsync()
|
protected override async Task InitializeDataAsync()
|
||||||
{
|
{
|
||||||
|
var filter = await LocalStorageService.GetItem<ProspectFilter>(StorageKeys.ProspectFilter);
|
||||||
|
if (filter != null) Filter = filter;
|
||||||
|
|
||||||
// Load prospects
|
// Load prospects
|
||||||
await LoadProspects();
|
await LoadProspects();
|
||||||
}
|
}
|
||||||
@@ -63,6 +65,21 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Private Method FilterChangedAsync
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current filter with the specified ProspectFilter object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg">The ProspectFilter object containing the updated filter criteria.</param>
|
||||||
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||||
|
private async Task FilterChangedAsync(ProspectFilter arg)
|
||||||
|
{
|
||||||
|
Filter = arg;
|
||||||
|
await LocalStorageService.SetItem(StorageKeys.ProspectFilter, Filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Private Method LoadProspects
|
#region Private Method LoadProspects
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<ProspectFilterControl @bind-Filter="Filter" StateFilter="ProspectStateFilter.All"></ProspectFilterControl>
|
<ProspectFilterControl Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.All"></ProspectFilterControl>
|
||||||
<hr />
|
<hr />
|
||||||
<ProspectGrid
|
<ProspectGrid
|
||||||
Prospects="filterList"
|
Prospects="filterList"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using FoodsharingSiegen.Contracts;
|
||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
using FoodsharingSiegen.Contracts.Helper;
|
using FoodsharingSiegen.Contracts.Helper;
|
||||||
using FoodsharingSiegen.Contracts.Model;
|
using FoodsharingSiegen.Contracts.Model;
|
||||||
@@ -46,12 +47,31 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
{
|
{
|
||||||
if(!CurrentUser.IsAdmin()) NavigationManager.NavigateTo("/");
|
if(!CurrentUser.IsAdmin()) NavigationManager.NavigateTo("/");
|
||||||
|
|
||||||
|
// Load Filter
|
||||||
|
var filter = await LocalStorageService.GetItem<ProspectFilter>(StorageKeys.ProspectFilter);
|
||||||
|
if (filter != null) Filter = filter;
|
||||||
|
|
||||||
// Load prospects
|
// Load prospects
|
||||||
await LoadProspects();
|
await LoadProspects();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Private Method FilterChangedAsync
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current filter with the specified ProspectFilter object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg">The ProspectFilter object containing the updated filter criteria.</param>
|
||||||
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||||
|
private async Task FilterChangedAsync(ProspectFilter arg)
|
||||||
|
{
|
||||||
|
Filter = arg;
|
||||||
|
await LocalStorageService.SetItem(StorageKeys.ProspectFilter, Filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Private Method LoadProspects
|
#region Private Method LoadProspects
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
<ProspectFilterControl @bind-Filter="Filter" StateFilter="ProspectStateFilter.Completed"></ProspectFilterControl>
|
<ProspectFilterControl Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.Completed"></ProspectFilterControl>
|
||||||
<hr />
|
<hr />
|
||||||
<ProspectGrid
|
<ProspectGrid
|
||||||
Prospects="filterList"
|
Prospects="filterList"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using FoodsharingSiegen.Contracts;
|
||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
using FoodsharingSiegen.Contracts.Enums;
|
using FoodsharingSiegen.Contracts.Enums;
|
||||||
using FoodsharingSiegen.Contracts.Model;
|
using FoodsharingSiegen.Contracts.Model;
|
||||||
@@ -37,11 +38,30 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override async Task InitializeDataAsync()
|
protected override async Task InitializeDataAsync()
|
||||||
{
|
{
|
||||||
|
// Load Filter
|
||||||
|
var filter = await LocalStorageService.GetItem<ProspectFilter>(StorageKeys.ProspectFilter);
|
||||||
|
if (filter != null) Filter = filter;
|
||||||
|
|
||||||
await LoadProspects();
|
await LoadProspects();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Private Method FilterChangedAsync
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current filter with the specified ProspectFilter object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg">The ProspectFilter object containing the updated filter criteria.</param>
|
||||||
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||||
|
private async Task FilterChangedAsync(ProspectFilter arg)
|
||||||
|
{
|
||||||
|
Filter = arg;
|
||||||
|
await LocalStorageService.SetItem(StorageKeys.ProspectFilter, Filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Private Method LoadProspects
|
#region Private Method LoadProspects
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<ProspectFilterControl @bind-Filter="Filter" StateFilter="ProspectStateFilter.Verification"></ProspectFilterControl>
|
<ProspectFilterControl Filter="Filter" FilterChanged="FilterChangedAsync" StateFilter="ProspectStateFilter.Verification"></ProspectFilterControl>
|
||||||
<hr />
|
<hr />
|
||||||
<ProspectGrid
|
<ProspectGrid
|
||||||
Prospects="filterList"
|
Prospects="filterList"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
using FoodsharingSiegen.Contracts;
|
||||||
using FoodsharingSiegen.Contracts.Entity;
|
using FoodsharingSiegen.Contracts.Entity;
|
||||||
using FoodsharingSiegen.Contracts.Enums;
|
using FoodsharingSiegen.Contracts.Enums;
|
||||||
using FoodsharingSiegen.Contracts.Model;
|
using FoodsharingSiegen.Contracts.Model;
|
||||||
using FoodsharingSiegen.Server.Data.Service;
|
using FoodsharingSiegen.Server.Data.Service;
|
||||||
using FoodsharingSiegen.Server.Dialogs;
|
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
namespace FoodsharingSiegen.Server.Pages
|
namespace FoodsharingSiegen.Server.Pages
|
||||||
@@ -44,12 +44,31 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override async Task InitializeDataAsync()
|
protected override async Task InitializeDataAsync()
|
||||||
{
|
{
|
||||||
|
// Load Filter
|
||||||
|
var filter = await LocalStorageService.GetItem<ProspectFilter>(StorageKeys.ProspectFilter);
|
||||||
|
if (filter != null) Filter = filter;
|
||||||
|
|
||||||
// Load prospects
|
// Load prospects
|
||||||
await LoadProspects();
|
await LoadProspects();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Private Method FilterChangedAsync
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current filter with the specified ProspectFilter object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="arg">The ProspectFilter object containing the updated filter criteria.</param>
|
||||||
|
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||||
|
private async Task FilterChangedAsync(ProspectFilter arg)
|
||||||
|
{
|
||||||
|
Filter = arg;
|
||||||
|
await LocalStorageService.SetItem(StorageKeys.ProspectFilter, Filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Private Method LoadProspects
|
#region Private Method LoadProspects
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user