Add search to games. Increase page size to 25
This commit is contained in:
parent
b6a448a289
commit
aa17cb5090
1 changed files with 20 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
@page "/Games"
|
@page "/Games"
|
||||||
|
@using AntDesign.TableModels;
|
||||||
@using LANCommander.Extensions;
|
@using LANCommander.Extensions;
|
||||||
@using System.ComponentModel.DataAnnotations;
|
@using System.ComponentModel.DataAnnotations;
|
||||||
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
|
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
|
||||||
|
@ -9,7 +10,14 @@
|
||||||
|
|
||||||
<PageHeader Title="Games">
|
<PageHeader Title="Games">
|
||||||
<PageHeaderExtra>
|
<PageHeaderExtra>
|
||||||
|
<Space Direction="DirectionVHType.Horizontal">
|
||||||
|
<SpaceItem>
|
||||||
|
<Search Placeholder="Search" @bind-Value="Search" BindOnInput DebounceMilliseconds="150" OnChange="() => LoadData()" />
|
||||||
|
</SpaceItem>
|
||||||
|
<SpaceItem>
|
||||||
<Button OnClick="() => Add()" Type="@ButtonType.Primary">Add Game</Button>
|
<Button OnClick="() => Add()" Type="@ButtonType.Primary">Add Game</Button>
|
||||||
|
</SpaceItem>
|
||||||
|
</Space>
|
||||||
</PageHeaderExtra>
|
</PageHeaderExtra>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
|
|
||||||
|
@ -35,7 +43,7 @@
|
||||||
</Space>
|
</Space>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
|
||||||
<Table TItem="Game" DataSource="@Games" Loading="@Loading">
|
<Table @ref="Table" TItem="Game" DataSource="@Games" Loading="@Loading" PageSize="25">
|
||||||
@if (FieldVisible(Field.Icon))
|
@if (FieldVisible(Field.Icon))
|
||||||
{
|
{
|
||||||
<Column TData="string">
|
<Column TData="string">
|
||||||
|
@ -192,6 +200,10 @@
|
||||||
bool Loading = true;
|
bool Loading = true;
|
||||||
bool FieldPickerVisible = false;
|
bool FieldPickerVisible = false;
|
||||||
|
|
||||||
|
string Search = "";
|
||||||
|
|
||||||
|
ITable Table;
|
||||||
|
|
||||||
Dictionary<Field, bool> FieldVisibility = new Dictionary<Field, bool>()
|
Dictionary<Field, bool> FieldVisibility = new Dictionary<Field, bool>()
|
||||||
{
|
{
|
||||||
{ Field.Icon, true },
|
{ Field.Icon, true },
|
||||||
|
@ -239,7 +251,7 @@
|
||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
Games = GameService.Get().OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToList();
|
LoadData();
|
||||||
|
|
||||||
Loading = false;
|
Loading = false;
|
||||||
|
|
||||||
|
@ -252,6 +264,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
Games = GameService.Get(g => g.Title.ToLower().Contains(Search.ToLower().Trim()) || g.SortTitle.ToLower().Contains(Search.ToLower().Trim())).OrderBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
private bool FieldVisible(Field field)
|
private bool FieldVisible(Field field)
|
||||||
{
|
{
|
||||||
return FieldVisibility.ContainsKey(field) && FieldVisibility[field] == true;
|
return FieldVisibility.ContainsKey(field) && FieldVisibility[field] == true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue