Apply sort and game filter
All checks were successful
Game Ideas build for PR / build_blazor_app (pull_request) Successful in 1m2s
All checks were successful
Game Ideas build for PR / build_blazor_app (pull_request) Successful in 1m2s
This commit is contained in:
@@ -7,8 +7,8 @@
|
||||
@using GameIdeas.Shared.Dto
|
||||
|
||||
<div class="form-filter">
|
||||
<Select TItem="SortPropertyDto" ValuesChanged=HandleSortPropertyClicked
|
||||
THeader="SortTypeDto" HeaderValuesChanged=HandleSortTypeClicked
|
||||
<Select TItem="SortPropertyDto" Values="[Value.SortProperty]" ValuesChanged=HandleSortPropertyClicked
|
||||
THeader="SortTypeDto" HeaderValues="[Value.SortType]" HeaderValuesChanged=HandleSortTypeClicked
|
||||
Params=SelectParams Theme="SelectTheme.Sort" >
|
||||
<div class="square-button">
|
||||
<svg class="sort-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||
using GameIdeas.BlazorApp.Shared.Components.SliderRange;
|
||||
using GameIdeas.BlazorApp.Shared.Models;
|
||||
using GameIdeas.Resources;
|
||||
using GameIdeas.Shared.Dto;
|
||||
using GameIdeas.Shared.Enum;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
@@ -15,17 +16,18 @@ public partial class GameFilter
|
||||
[Parameter] public EventCallback<DisplayType> DisplayTypeChanged { get; set; }
|
||||
[Parameter] public CategoriesDto? Categories { get; set; }
|
||||
|
||||
|
||||
private readonly List<SortTypeDto> SortTypes = [
|
||||
new() { SortType = SortType.Ascending, Label = "Ascendant" },
|
||||
new() { SortType = SortType.Descending, Label = "Descendant" }
|
||||
public static readonly List<SortTypeDto> SortTypes = [
|
||||
new() { SortType = SortType.Ascending, Label = ResourcesKey.Ascending },
|
||||
new() { SortType = SortType.Descending, Label = ResourcesKey.Descending }
|
||||
];
|
||||
|
||||
private readonly List<SortPropertyDto> GameProperties = [
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.Title), Label = "Titre" },
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.ReleaseDate), Label = "Date de parution" },
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.StorageSpace), Label = "Espace de stockage" },
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.Interest), Label = "Inter<65>t" }
|
||||
public static readonly List<SortPropertyDto> GameProperties = [
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.Title), Label = ResourcesKey.Title },
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.ReleaseDate), Label = ResourcesKey.ReleaseDate },
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.CreationDate), Label = ResourcesKey.CreateDate },
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.ModificationDate), Label = ResourcesKey.UpdateDate },
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.StorageSpace), Label = ResourcesKey.StorageSize },
|
||||
new() { PropertyName = nameof(GameIdeas.Shared.Model.Game.Interest), Label = ResourcesKey.Interest }
|
||||
];
|
||||
|
||||
private SelectParams<SortPropertyDto, SortTypeDto> SelectParams = new();
|
||||
@@ -37,10 +39,8 @@ public partial class GameFilter
|
||||
{
|
||||
Headers = SortTypes,
|
||||
GetHeaderLabel = header => header.Label,
|
||||
DefaultHeaders = SortTypes.Where(h => h.SortType == SortType.Ascending).ToList(),
|
||||
Items = GameProperties,
|
||||
GetItemLabel = item => item.Label,
|
||||
DefaultItems = GameProperties.Where(p => p.PropertyName == nameof(GameDetailDto.Title)).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||
using GameIdeas.BlazorApp.Shared.Components.Popup;
|
||||
using GameIdeas.BlazorApp.Shared.Models;
|
||||
using GameIdeas.Shared.Dto;
|
||||
using GameIdeas.Shared.Enum;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Pages.Games;
|
||||
@@ -21,6 +22,12 @@ public partial class Game
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
CurrentPage = 1;
|
||||
GameFilter.SortType = Filter.GameFilter.SortTypes
|
||||
.First(st => st.SortType == SortType.Ascending);
|
||||
|
||||
GameFilter.SortProperty= Filter.GameFilter.GameProperties
|
||||
.First(gp => gp.PropertyName == nameof(GameIdeas.Shared.Model.Game.Title));
|
||||
|
||||
await HandleFetchDatas(true);
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ public partial class GameHeader : ComponentBase
|
||||
SelectParams = new()
|
||||
{
|
||||
Items = AddTypes.ToList(),
|
||||
GetItemLabel = item => item.Value,
|
||||
DefaultItems = []
|
||||
GetItemLabel = item => item.Value
|
||||
};
|
||||
|
||||
base.OnInitialized();
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
public class SelectParams<TItem, THeader>
|
||||
{
|
||||
public List<TItem> Items { get; set; } = [];
|
||||
public List<TItem> DefaultItems { get; set; } = [];
|
||||
public Func<TItem, string> GetItemLabel { get; set; } = _ => string.Empty;
|
||||
public List<THeader> Headers { get; set; } = [];
|
||||
public List<THeader> DefaultHeaders { get; set; } = [];
|
||||
public Func<THeader, string> GetHeaderLabel { get; set; } = _ => string.Empty;
|
||||
public Func<string, TItem>? AddItem { get; set; }
|
||||
|
||||
|
||||
@@ -37,16 +37,6 @@ public partial class Select<TItem, THeader>
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
QuickAddEditContext = new EditContext(AddLabel);
|
||||
|
||||
if (Params.DefaultItems.Count != 0)
|
||||
{
|
||||
Values.AddRange(Params.DefaultItems);
|
||||
}
|
||||
|
||||
if (Params.DefaultHeaders.Count != 0)
|
||||
{
|
||||
HeaderValues.AddRange(Params.DefaultHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleButtonClicked()
|
||||
|
||||
Reference in New Issue
Block a user