feature/apply-filter (#18)
Co-authored-by: Maxime Adler <madler@sqli.com> Reviewed-on: #18
This commit was merged in pull request #18.
This commit is contained in:
@@ -4,7 +4,7 @@ namespace GameIdeas.BlazorApp.Helpers;
|
||||
|
||||
public static class GameHelper
|
||||
{
|
||||
public static void WriteTrackingDto(GameDto game)
|
||||
public static void WriteTrackingDto(GameDetailDto game)
|
||||
{
|
||||
game.CreationUserId = 100000;
|
||||
game.CreationDate = DateTime.Now;
|
||||
@@ -22,4 +22,19 @@ public static class GameHelper
|
||||
_ => "--yellow",
|
||||
};
|
||||
}
|
||||
|
||||
public static string GetFormatedStorageSpace(double? storageValue)
|
||||
{
|
||||
if (storageValue == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return storageValue switch
|
||||
{
|
||||
>= 1000000 => $"{storageValue / 1000000:f1} To",
|
||||
>= 1000 => $"{storageValue / 1000:f1} Go",
|
||||
_ => $"{storageValue:f1} Mo"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Helpers;
|
||||
|
||||
public static class UrlHelper
|
||||
{
|
||||
public static string BuildUrlParams(object? model)
|
||||
{
|
||||
if (model == null)
|
||||
return string.Empty;
|
||||
|
||||
var properties = model.GetType().GetProperties();
|
||||
var queryParams = properties
|
||||
.Select(p =>
|
||||
{
|
||||
var value = p.GetValue(model);
|
||||
|
||||
switch (value)
|
||||
{
|
||||
case null:
|
||||
return null;
|
||||
case DateTime dateTime:
|
||||
return $"{p.Name}={Uri.EscapeDataString(dateTime.ToString("yyyy-MM-dd HH:mm:ss"))}";
|
||||
}
|
||||
|
||||
if (value is IEnumerable enumerable and not string)
|
||||
{
|
||||
var items = enumerable.Cast<object>()
|
||||
.Select(item => $"{p.Name}={Uri.EscapeDataString(item?.ToString() ?? string.Empty)}");
|
||||
return string.Join("&", items);
|
||||
}
|
||||
|
||||
return $"{p.Name}={Uri.EscapeDataString(value.ToString() ?? string.Empty)}";
|
||||
})
|
||||
.ToArray();
|
||||
return string.Join("&", queryParams.Where(p => p != null));
|
||||
}
|
||||
}
|
||||
@@ -12,19 +12,4 @@ public class GameBase : ComponentBase
|
||||
{
|
||||
NavigationManager.NavigateTo($"/Games/Detail/{GameDto.Id}");
|
||||
}
|
||||
|
||||
protected string GetFormatedStorageSpace()
|
||||
{
|
||||
if (GameDto.StorageSpace == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return GameDto.StorageSpace switch
|
||||
{
|
||||
>= 1000000 => $"{GameDto.StorageSpace / 1000000:f1} To",
|
||||
>= 1000 => $"{GameDto.StorageSpace / 1000:f1} Go",
|
||||
_ => $"{GameDto.StorageSpace:f1} Mo"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public partial class GameCreationForm
|
||||
[Parameter] public CategoriesDto? Categories { get; set; }
|
||||
[Parameter] public EventCallback OnSubmit { get; set; }
|
||||
|
||||
private GameDto GameDto = new();
|
||||
private GameDetailDto GameDto = new();
|
||||
private EditContext? EditContext;
|
||||
private readonly SelectTheme Theme = SelectTheme.Creation;
|
||||
private readonly SliderParams SliderParams = new() { Gap = 1, Min = 1, Max = 5 };
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
<span class="storage">@GetFormatedStorageSpace()</span>
|
||||
<span class="storage">@GameHelper.GetFormatedStorageSpace(GameDto.StorageSpace)</span>
|
||||
|
||||
<div class="interest">
|
||||
<span class="value" style="@($"color: var({GameHelper.GetInterestColor(GameDto.Interest, 5)})")">
|
||||
|
||||
@@ -4,7 +4,7 @@ using GameIdeas.Shared.Dto;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Pages.Games.Components;
|
||||
|
||||
public class GameValidation : AbstractValidator<GameDto>
|
||||
public class GameValidation : AbstractValidator<GameDetailDto>
|
||||
{
|
||||
public GameValidation()
|
||||
{
|
||||
|
||||
@@ -22,5 +22,11 @@
|
||||
<SelectSearch TItem="PublisherDto" Placeholder="@ResourcesKey.Publishers" GetLabel="@(p => p.Name)"
|
||||
@bind-Values=GameFilter.Publishers @bind-Values:after=HandleValueChanged Theme="Theme" Items="Categories?.Publishers" />
|
||||
|
||||
<SelectSearch TItem="int" Placeholder="@ResourcesKey.ReleaseDate" GetLabel="@(p => p.ToString())"
|
||||
@bind-Values=GameFilter.ReleaseYears @bind-Values:after=HandleValueChanged Theme="Theme" Items="Categories?.ReleaseYears" />
|
||||
|
||||
<SelectSearch TItem="int" Placeholder="@ResourcesKey.StorageSize" GetLabel="@GetStorageSpaceLabel"
|
||||
@bind-Values=GameFilter.StorageSpaceIds @bind-Values:after=HandleValueChanged Theme="Theme" Items="@(Categories?.StorageSpaces?.Select(stor => stor.Id).ToList())" />
|
||||
|
||||
<span class="title">@ResourcesKey.LastAdd</span>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using GameIdeas.BlazorApp.Helpers;
|
||||
using GameIdeas.BlazorApp.Pages.Games.Header;
|
||||
using GameIdeas.BlazorApp.Shared.Components.Select.Models;
|
||||
using GameIdeas.Resources;
|
||||
using GameIdeas.Shared.Dto;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
@@ -6,9 +9,9 @@ namespace GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||
|
||||
public partial class AdvancedGameFilter
|
||||
{
|
||||
[Parameter] public GameFilterDto GameFilter { get; set; } = new();
|
||||
[Parameter] public GameFilterParams GameFilter { get; set; } = new();
|
||||
[Parameter] public CategoriesDto? Categories { get; set; }
|
||||
[Parameter] public EventCallback<GameFilterDto> GameFilterChanged { get; set; }
|
||||
[Parameter] public EventCallback<GameFilterParams> GameFilterChanged { get; set; }
|
||||
|
||||
private readonly SelectTheme Theme = SelectTheme.AdvancedFilter;
|
||||
|
||||
@@ -16,4 +19,31 @@ public partial class AdvancedGameFilter
|
||||
{
|
||||
await GameFilterChanged.InvokeAsync(GameFilter);
|
||||
}
|
||||
|
||||
private string GetStorageSpaceLabel(int storageSpaceId)
|
||||
{
|
||||
var storageSpace = Categories?.StorageSpaces?.FirstOrDefault(c => c.Id == storageSpaceId)
|
||||
?? throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
|
||||
|
||||
if (storageSpace.MinSize == null && storageSpace.MaxSize != null)
|
||||
{
|
||||
return string.Format(ResourcesKey.MinStorageSpaceFormat,
|
||||
GameHelper.GetFormatedStorageSpace(storageSpace.MaxSize));
|
||||
}
|
||||
|
||||
if (storageSpace.MinSize != null && storageSpace.MaxSize == null)
|
||||
{
|
||||
return string.Format(ResourcesKey.MaxStorageSpaceFormat,
|
||||
GameHelper.GetFormatedStorageSpace(storageSpace.MinSize));
|
||||
}
|
||||
|
||||
if (storageSpace.MinSize != null && storageSpace.MaxSize != null)
|
||||
{
|
||||
return string.Format(ResourcesKey.MinMaxStorageSpaceFormat,
|
||||
GameHelper.GetFormatedStorageSpace(storageSpace.MinSize),
|
||||
GameHelper.GetFormatedStorageSpace(storageSpace.MaxSize));
|
||||
}
|
||||
|
||||
throw new ArgumentNullException(ResourcesKey.ErrorStorageSpaceLabel);
|
||||
}
|
||||
}
|
||||
@@ -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">
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
<div class="search-container">
|
||||
<SearchInput @bind-Text="@Value.Title"
|
||||
@bind-Text:after="HandleValueChanged"
|
||||
Placeholder="@ResourcesKey.Research" />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,30 +1,33 @@
|
||||
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;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||
|
||||
public partial class GameFilter
|
||||
{
|
||||
[Parameter] public GameFilterDto Value { get; set; } = new();
|
||||
[Parameter] public EventCallback<GameFilterDto> ValueChanged { get; set; }
|
||||
[Parameter] public GameFilterParams Value { get; set; } = new();
|
||||
[Parameter] public EventCallback<GameFilterParams> ValueChanged { get; set; }
|
||||
[Parameter] public DisplayType DisplayType { get; set; }
|
||||
[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() { SortProperty = game => game.Title!, Label = "Titre" },
|
||||
new() { SortProperty = game => game.ReleaseDate!, Label = "Date de parution" }
|
||||
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();
|
||||
@@ -36,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.Label == "Titre").ToList()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using GameIdeas.Shared.Dto;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||
|
||||
public class GameFilterParams
|
||||
{
|
||||
public SortTypeDto? SortType { get; set; }
|
||||
public SortPropertyDto? SortProperty { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public List<PlatformDto>? Platforms { get; set; }
|
||||
public List<PropertyDto>? Properties { get; set; }
|
||||
public List<TagDto>? Tags { get; set; }
|
||||
public List<PublisherDto>? Publishers { get; set; }
|
||||
public List<DeveloperDto>? Developers { get; set; }
|
||||
public int MinInterest { get; set; } = 1;
|
||||
public int MaxInterest { get; set; } = 5;
|
||||
public List<int>? ReleaseYears { get; set; }
|
||||
public List<int>? StorageSpaceIds { get; set; }
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
<GameHeader AddTypeChanged="HandleAddClicked">
|
||||
<GameFilter Categories="Categories"
|
||||
@bind-DisplayType=DisplayType
|
||||
@bind-Value=GameFilter />
|
||||
Value=GameFilter ValueChanged="HandleFilterChanged" />
|
||||
</GameHeader>
|
||||
|
||||
<div class="container">
|
||||
@@ -36,9 +36,9 @@
|
||||
|
||||
</div>
|
||||
|
||||
<AdvancedGameFilter @bind-GameFilter=GameFilter Categories="Categories" />
|
||||
<AdvancedGameFilter GameFilter=GameFilter GameFilterChanged="HandleFilterChanged" Categories="Categories" />
|
||||
</div>
|
||||
|
||||
<Popup @ref=ManualAddPopup BackdropFilterClicked="HandleBackdropManualAddClicked" Closable=false>
|
||||
<GameCreationForm Categories="Categories" OnSubmit="HandleFetchDatas" />
|
||||
<GameCreationForm Categories="Categories" OnSubmit="() => HandleFetchDatas()" />
|
||||
</Popup>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||
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;
|
||||
@@ -11,17 +13,26 @@ public partial class Game
|
||||
[Inject] private IGameGateway GameGateway { get; set; } = default!;
|
||||
|
||||
private DisplayType DisplayType = DisplayType.List;
|
||||
private GameFilterDto GameFilter = new();
|
||||
private GameFilterParams GameFilter = new();
|
||||
private Popup? ManualAddPopup;
|
||||
private bool IsLoading = false;
|
||||
private CategoriesDto? Categories;
|
||||
private IEnumerable<GameDto> GamesDto = [];
|
||||
private int CurrentPage;
|
||||
|
||||
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();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
private void HandleAddClicked(AddType addType)
|
||||
{
|
||||
switch (addType)
|
||||
@@ -39,14 +50,16 @@ public partial class Game
|
||||
{
|
||||
ManualAddPopup?.Close();
|
||||
}
|
||||
private async Task HandleFetchDatas()
|
||||
private async Task HandleFetchDatas(bool loadCategories = true, bool displayLoader = true)
|
||||
{
|
||||
try
|
||||
{
|
||||
IsLoading = true;
|
||||
IsLoading = displayLoader;
|
||||
|
||||
Categories = await GameGateway.FetchCategories();
|
||||
GamesDto = await GameGateway.FetchGames(new PaggingDto() { CurrentPage = 1, NumberPerPage = 50 });
|
||||
if (loadCategories)
|
||||
Categories = await GameGateway.FetchCategories();
|
||||
|
||||
GamesDto = await GameGateway.FetchGames(GameFilter, CurrentPage);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -57,4 +70,9 @@ public partial class Game
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
private async Task HandleFilterChanged(GameFilterParams args)
|
||||
{
|
||||
GameFilter = args;
|
||||
await HandleFetchDatas(loadCategories: false, displayLoader: false);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using GameIdeas.BlazorApp.Services;
|
||||
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||
using GameIdeas.BlazorApp.Services;
|
||||
using GameIdeas.BlazorApp.Shared.Constants;
|
||||
using GameIdeas.BlazorApp.Shared.Exceptions;
|
||||
using GameIdeas.Resources;
|
||||
@@ -8,7 +9,7 @@ namespace GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||
|
||||
public class GameGateway(IHttpClientService httpClientService) : IGameGateway
|
||||
{
|
||||
public async Task<int> CreateGame(GameDto game)
|
||||
public async Task<int> CreateGame(GameDetailDto game)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -34,11 +35,26 @@ public class GameGateway(IHttpClientService httpClientService) : IGameGateway
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<GameDto>> FetchGames(PaggingDto pagging)
|
||||
public async Task<IEnumerable<GameDto>> FetchGames(GameFilterParams filterParams, int currentPage)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await httpClientService.FetchDataAsync<IEnumerable<GameDto>>(Endpoints.Game.Fetch(pagging));
|
||||
GameFilterDto filter = new()
|
||||
{
|
||||
CurrentPage = currentPage,
|
||||
Title = filterParams.Title,
|
||||
MaxInterest = filterParams.MaxInterest,
|
||||
MinInterest = filterParams.MinInterest,
|
||||
StorageSpaces = filterParams.StorageSpaceIds,
|
||||
DeveloperIds = filterParams.Developers?.Select(d => d.Id ?? 0).ToList(),
|
||||
PublisherIds = filterParams.Publishers?.Select(d => d.Id ?? 0).ToList(),
|
||||
PlatformIds = filterParams.Platforms?.Select(d => d.Id ?? 0).ToList(),
|
||||
PropertyIds = filterParams.Properties?.Select(d => d.Id ?? 0).ToList(),
|
||||
ReleaseYears = filterParams.ReleaseYears,
|
||||
TagIds = filterParams.Tags?.Select(d => d.Id ?? 0).ToList(),
|
||||
};
|
||||
|
||||
var result = await httpClientService.FetchDataAsync<IEnumerable<GameDto>>(Endpoints.Game.Fetch(filter));
|
||||
return result ?? throw new InvalidOperationException(ResourcesKey.ErrorFetchGames);
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using GameIdeas.Shared.Dto;
|
||||
using GameIdeas.BlazorApp.Pages.Games.Filter;
|
||||
using GameIdeas.Shared.Dto;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Pages.Games.Gateways;
|
||||
|
||||
public interface IGameGateway
|
||||
{
|
||||
Task<CategoriesDto> FetchCategories();
|
||||
Task<int> CreateGame(GameDto game);
|
||||
Task<IEnumerable<GameDto>> FetchGames(PaggingDto pagging);
|
||||
Task<int> CreateGame(GameDetailDto game);
|
||||
Task<IEnumerable<GameDto>> FetchGames(GameFilterParams filter, int currentPage);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
@using GameIdeas.Shared.Constants
|
||||
|
||||
<div class="search-container">
|
||||
<input @ref=InputText
|
||||
<input id="searchInput"
|
||||
type="text"
|
||||
class="search-field"
|
||||
placeholder="@Placeholder"
|
||||
@@ -10,7 +10,7 @@
|
||||
style="@(IsDisable ? "pointer-events: none" : "")"
|
||||
@bind=@Text
|
||||
@bind:event="oninput"
|
||||
@bind:after=HandleTextChanged
|
||||
@bind:after="HandleTextChanged"
|
||||
@onfocusin=HandleFocusIn/>
|
||||
|
||||
<div class="buttons">
|
||||
@@ -25,5 +25,4 @@
|
||||
@GetSearchIcon()
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -1,5 +1,4 @@
|
||||
using GameIdeas.BlazorApp.Shared.Constants;
|
||||
using GameIdeas.Shared.Constants;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Shared.Components.Search;
|
||||
@@ -15,21 +14,31 @@ public partial class SearchInput
|
||||
[Parameter] public EventCallback FocusIn { get; set; }
|
||||
[Parameter] public SearchInputIcon Icon { get; set; }
|
||||
|
||||
private ElementReference InputText;
|
||||
private System.Timers.Timer? Timer;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Text = string.Empty;
|
||||
Timer = new()
|
||||
{
|
||||
Interval = 500,
|
||||
AutoReset = false,
|
||||
};
|
||||
|
||||
Timer.Elapsed += async (_, _) => await TextChanged.InvokeAsync(Text);
|
||||
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
public void SetText(string str)
|
||||
{
|
||||
Text = str;
|
||||
}
|
||||
|
||||
private async Task HandleTextChanged()
|
||||
|
||||
private void HandleTextChanged()
|
||||
{
|
||||
await TextChanged.InvokeAsync(Text);
|
||||
Timer?.Stop();
|
||||
Timer?.Start();
|
||||
}
|
||||
|
||||
private async Task HandleClearClicked()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GameIdeas.Shared.Dto;
|
||||
using GameIdeas.BlazorApp.Helpers;
|
||||
using GameIdeas.Shared.Dto;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Shared.Constants;
|
||||
|
||||
@@ -7,8 +8,7 @@ public static class Endpoints
|
||||
public static class Game
|
||||
{
|
||||
public static readonly string Create = "api/Game/Create";
|
||||
public static string Fetch(PaggingDto pagging) =>
|
||||
$"api/Game?{nameof(pagging.CurrentPage)}={pagging.CurrentPage}&{nameof(pagging.NumberPerPage)}={pagging.NumberPerPage}";
|
||||
public static string Fetch(GameFilterDto filter) => $"api/Game?{UrlHelper.BuildUrlParams(filter)}";
|
||||
}
|
||||
|
||||
public static class Category
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
</div>
|
||||
<script src="_framework/blazor.webassembly.js"></script>
|
||||
<script src="Shared/Components/BackdropFilter/BackdropFilter.razor.js"></script>
|
||||
<script src="Shared/Components/Select/MultipleSelectList.razor.js"></script>
|
||||
<script src="Pages/Games/Components/GameCreationForm.razor.js"></script>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user