btcpayserver/BTCPayServer/Components/Pager/Default.cshtml
d11n bfdb1b4af9
Design updates (#3565)
* Design updates

* Improve table styles

* Form input color improvements

* Form input shadows

* Increase accordion button padding

* Hover transition for checkboxes and radio buttons

* Improve checkbox and radio button spacings

* Improve input styles

* Secondary button updates

* Clear pager floats

* Link improvements

* Don't display border for last table row
2022-04-11 17:49:57 +09:00

86 lines
2.8 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@model BasePagingViewModel
@{
var pageSizeOptions = new [] { 50, 100, 250, 500 };
}
@if (Model.Total > pageSizeOptions.Min())
{
<nav aria-label="..." class="w-100 clearfix">
@if (Model.Total > Model.Count)
{
<ul class="pagination float-start">
<li class="page-item @(Model.Skip == 0 ? "disabled" : null)">
<a class="page-link" tabindex="-1" href="@NavigatePages(-1, Model.Count)">&laquo;</a>
</li>
<li class="page-item disabled">
@if (Model.Total <= Model.Count)
{
<span class="page-link">
1@Model.Total
</span>
}
else
{
<span class="page-link">
@(Model.Skip + 1)@(Model.Skip + Model.Count), Total: @Model.Total
</span>
}
</li>
<li class="page-item @(Model.Total > (Model.Skip + Model.Count) ? null : "disabled")">
<a class="page-link" href="@NavigatePages(1, Model.Count)">&raquo;</a>
</li>
</ul>
}
@if (Model.Total >= pageSizeOptions.Min())
{
<ul class="pagination float-end">
<li class="page-item disabled">
<span class="page-link">Page Size:</span>
</li>
@foreach (int pageSize in pageSizeOptions)
{
if (Model.Total >= pageSize)
{
<li class="page-item @(Model.Count == pageSize ? "active" : null)">
<a class="page-link" href="@NavigatePages(0, pageSize)">@pageSize</a>
</li>
}
}
</ul>
}
</nav>
}
@{
string NavigatePages(int prevNext, int count)
{
var skip = Model.Skip;
if (prevNext == -1)
{
skip = Math.Max(0, Model.Skip - Model.Count);
}
else if (prevNext == 1)
{
skip = Model.Skip + count;
}
var query = new Dictionary<string, object>
{
{ "searchTerm", Model.SearchTerm },
{ "timezoneOffset", Model.TimezoneOffset },
{ "skip", skip },
{ "count", count }
};
if (Model.PaginationQuery != null)
{
// merge both, prefering the `query` properties in case of duplicate keys
query = query.Concat(Model.PaginationQuery)
.GroupBy(e => e.Key)
.ToDictionary(g => g.Key, g => g.First().Value);
}
return Url.Action(null, query);
}
}