Updated pager.

This commit is contained in:
2025-11-10 20:31:50 -05:00
parent 9cd9230cec
commit e2c39cf581
4 changed files with 77 additions and 10 deletions

View File

@@ -3,6 +3,14 @@
<label>@IndexInfo</label> <label>@IndexInfo</label>
</div> </div>
<MudPagination ShowFirstButton="true" ShowLastButton="true" Count="@((int)Math.Ceiling((decimal)TotalItems / (decimal)PageSize))" Selected="@PageNumber" SelectedChanged="OnSelectedChanged" /> <MudPagination ShowFirstButton="true" ShowLastButton="true" Count="@((int)Math.Ceiling((decimal)TotalItems / (decimal)PageSize))" Selected="@PageNumber" SelectedChanged="OnSelectedChanged" />
<div>
<MudSelect T="int" Value="PageSize" ValueChanged="OnPageSizeChanged" Dense="true" Variant="Variant.Outlined" Margin="Margin.Dense">
@foreach (int value in PageSizes)
{
<MudSelectItem Value="@value">@value</MudSelectItem>
}
</MudSelect>
</div>
</div> </div>
@code { @code {
@@ -12,6 +20,9 @@
[Parameter] [Parameter]
public EventCallback<int> PageNumberChanged { get; set; } public EventCallback<int> PageNumberChanged { get; set; }
[Parameter]
public int[] PageSizes { get; set; } = [5, 10, 25, 50, 100];
[Parameter] [Parameter]
public int PageSize { get; set; } public int PageSize { get; set; }
@@ -34,4 +45,10 @@
PageNumber = newPage; PageNumber = newPage;
await PageNumberChanged.InvokeAsync(newPage); await PageNumberChanged.InvokeAsync(newPage);
} }
private async Task OnPageSizeChanged(int newPageSize)
{
PageSize = newPageSize;
await PageSizeChanged.InvokeAsync(newPageSize);
}
} }

View File

@@ -118,8 +118,7 @@ else
} }
</div> *@ </div> *@
<JPagination @bind-PageNumber="PageNumber" @bind-PageSize="pageSize" @bind-TotalItems="searchResults.TotalItems" /> <JPagination @bind-PageNumber="PageNumber" @bind-PageSize="PageSize" @bind-TotalItems="searchResults.TotalItems" />
@* <MudPagination ShowFirstButton="true" ShowLastButton="true" Count="@((int)Math.Ceiling((decimal)searchResults.TotalItems / (decimal)100))" @bind-Selected="@PageNumber" Class="j-pager" /> *@
} }
<style> <style>
@@ -177,6 +176,17 @@ else
} }
int pageSize = 100; int pageSize = 100;
public int PageSize
{
get { return pageSize; }
set
{
pageSize = value;
_ = UpdateDataAsync(true);
}
}
SearchResult<CircleSearchItem>? searchResults; SearchResult<CircleSearchItem>? searchResults;
protected override Task OnInitializedAsync() protected override Task OnInitializedAsync()

View File

@@ -4,6 +4,7 @@
@using JSMR.Application.Common.Search @using JSMR.Application.Common.Search
@using JSMR.Application.Creators.Queries.Search @using JSMR.Application.Creators.Queries.Search
@using JSMR.Application.Creators.Queries.Search.Contracts @using JSMR.Application.Creators.Queries.Search.Contracts
@using JSMR.UI.Blazor.Components
@using JSMR.UI.Blazor.Services @using JSMR.UI.Blazor.Services
<PageTitle>Creators</PageTitle> <PageTitle>Creators</PageTitle>
@@ -39,7 +40,7 @@ else
</Columns> </Columns>
</MudDataGrid> </MudDataGrid>
<MudPagination ShowFirstButton="true" ShowLastButton="true" Count="@((int)Math.Ceiling((decimal)searchResults.TotalItems / (decimal)100))" @bind-Selected="@PageNumber" Class="j-pager" /> <JPagination @bind-PageNumber="PageNumber" @bind-PageSize="PageSize" @bind-TotalItems="searchResults.TotalItems" />
} }
<style> <style>
@@ -68,7 +69,7 @@ else
set set
{ {
keywords = value; keywords = value;
_ = LoadTagsAsync(); _ = UpdateDataAsync(true);
} }
} }
@@ -80,21 +81,40 @@ else
set set
{ {
pageNumber = value; pageNumber = value;
_ = LoadTagsAsync(); _ = UpdateDataAsync(false);
} }
} }
int pageSize = 100; int pageSize = 100;
public int PageSize
{
get { return pageSize; }
set
{
pageSize = value;
_ = UpdateDataAsync(true);
}
}
SearchResult<CreatorSearchItem>? searchResults; SearchResult<CreatorSearchItem>? searchResults;
protected override Task OnInitializedAsync() protected override Task OnInitializedAsync()
{ {
_ = LoadTagsAsync(); _ = LoadCreatorsAsync();
return Task.CompletedTask; return Task.CompletedTask;
} }
private async Task LoadTagsAsync() private async Task UpdateDataAsync(bool resetPageNumber)
{
if (resetPageNumber)
pageNumber = 1;
await LoadCreatorsAsync();
}
private async Task LoadCreatorsAsync()
{ {
SearchCreatorsRequest request = new( SearchCreatorsRequest request = new(
Options: new() Options: new()

View File

@@ -4,6 +4,7 @@
@using JSMR.Application.Common.Search @using JSMR.Application.Common.Search
@using JSMR.Application.Tags.Queries.Search @using JSMR.Application.Tags.Queries.Search
@using JSMR.Application.Tags.Queries.Search.Contracts @using JSMR.Application.Tags.Queries.Search.Contracts
@using JSMR.UI.Blazor.Components
@using JSMR.UI.Blazor.Services @using JSMR.UI.Blazor.Services
<PageTitle>Tags</PageTitle> <PageTitle>Tags</PageTitle>
@@ -40,7 +41,7 @@ else
</Columns> </Columns>
</MudDataGrid> </MudDataGrid>
<MudPagination ShowFirstButton="true" ShowLastButton="true" Count="@((int)Math.Ceiling((decimal)searchResults.TotalItems / (decimal)100))" @bind-Selected="@PageNumber" Class="j-pager" /> <JPagination @bind-PageNumber="PageNumber" @bind-PageSize="PageSize" @bind-TotalItems="searchResults.TotalItems" />
} }
<style> <style>
@@ -69,7 +70,7 @@ else
set set
{ {
keywords = value; keywords = value;
_ = LoadTagsAsync(); _ = UpdateDataAsync(true);
} }
} }
@@ -81,11 +82,22 @@ else
set set
{ {
pageNumber = value; pageNumber = value;
_ = LoadTagsAsync(); _ = UpdateDataAsync(false);
} }
} }
int pageSize = 100; int pageSize = 100;
public int PageSize
{
get { return pageSize; }
set
{
pageSize = value;
_ = UpdateDataAsync(true);
}
}
SearchResult<TagSearchItem>? searchResults; SearchResult<TagSearchItem>? searchResults;
protected override Task OnInitializedAsync() protected override Task OnInitializedAsync()
@@ -95,6 +107,14 @@ else
return Task.CompletedTask; return Task.CompletedTask;
} }
private async Task UpdateDataAsync(bool resetPageNumber)
{
if (resetPageNumber)
pageNumber = 1;
await LoadTagsAsync();
}
private async Task LoadTagsAsync() private async Task LoadTagsAsync()
{ {
SearchTagsRequest request = new( SearchTagsRequest request = new(