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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user