feat: Add pagination to all list pages
Integrate Pager component into Jobs, Materials, Stock, Suppliers, and Tools index pages with a page size of 25. Handles page adjustment on delete when the last page becomes empty. Also removes the Description column from the Materials table. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -41,7 +41,7 @@ else
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in stockItems)
|
||||
@foreach (var item in pagedItems)
|
||||
{
|
||||
<tr>
|
||||
<td>@item.Material.Shape.GetDisplayName()</td>
|
||||
@@ -69,6 +69,8 @@ else
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<Pager TotalCount="stockItems.Count" PageSize="pageSize" CurrentPage="currentPage" CurrentPageChanged="OnPageChanged" />
|
||||
}
|
||||
|
||||
<ConfirmDialog @ref="deleteDialog"
|
||||
@@ -80,10 +82,14 @@ else
|
||||
@code {
|
||||
private List<StockItem> stockItems = new();
|
||||
private bool loading = true;
|
||||
private int currentPage = 1;
|
||||
private int pageSize = 25;
|
||||
private ConfirmDialog deleteDialog = null!;
|
||||
private StockItem? itemToDelete;
|
||||
private string deleteMessage = "";
|
||||
|
||||
private IEnumerable<StockItem> pagedItems => stockItems.Skip((currentPage - 1) * pageSize).Take(pageSize);
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
stockItems = await StockItemService.GetAllAsync();
|
||||
@@ -103,6 +109,12 @@ else
|
||||
{
|
||||
await StockItemService.DeleteAsync(itemToDelete.Id);
|
||||
stockItems = await StockItemService.GetAllAsync();
|
||||
|
||||
var totalPages = (int)Math.Ceiling((double)stockItems.Count / pageSize);
|
||||
if (currentPage > totalPages && totalPages > 0)
|
||||
currentPage = totalPages;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPageChanged(int page) => currentPage = page;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user