@namespace ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared
@* Reusable offset-pagination bar. Purely presentational: the host page
owns page-number state, query execution, and the HasNextPage decision.
Parameters: Page, PageChanged, HasNextPage, TotalCount, PageSize, Disabled. *@
@SummaryText
@code {
[Parameter] public int Page { get; set; } = 1;
[Parameter] public EventCallback PageChanged { get; set; }
[Parameter] public bool HasNextPage { get; set; }
[Parameter] public int? TotalCount { get; set; }
[Parameter] public int PageSize { get; set; }
[Parameter] public bool Disabled { get; set; }
private bool HasPrev => Page > 1;
private int? PageCount =>
TotalCount is { } t && PageSize > 0
? (int)Math.Ceiling(t / (double)PageSize)
: (int?)null;
private string SummaryText
{
get
{
var text = $"Page {Page}";
if (PageCount is { } pc) text += $" of {pc}";
if (TotalCount is { } total) text += $" ยท {total} total";
return text;
}
}
private Task OnPrevAsync() => PageChanged.InvokeAsync(Page - 1);
private Task OnNextAsync() => PageChanged.InvokeAsync(Page + 1);
}