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:
@@ -78,7 +78,7 @@ else
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var tool in tools)
|
||||
@foreach (var tool in pagedTools)
|
||||
{
|
||||
<tr>
|
||||
<td>@tool.Name</td>
|
||||
@@ -97,6 +97,8 @@ else
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<Pager TotalCount="tools.Count" PageSize="pageSize" CurrentPage="currentPage" CurrentPageChanged="OnPageChanged" />
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +114,10 @@ else
|
||||
private bool showForm;
|
||||
private bool saving;
|
||||
private string? errorMessage;
|
||||
private int currentPage = 1;
|
||||
private int pageSize = 25;
|
||||
|
||||
private IEnumerable<CuttingTool> pagedTools => tools.Skip((currentPage - 1) * pageSize).Take(pageSize);
|
||||
|
||||
private CuttingTool formTool = new();
|
||||
private CuttingTool? editingTool;
|
||||
@@ -207,9 +213,15 @@ else
|
||||
{
|
||||
await JobService.DeleteCuttingToolAsync(toolToDelete.Id);
|
||||
tools = await JobService.GetCuttingToolsAsync();
|
||||
|
||||
var totalPages = (int)Math.Ceiling((double)tools.Count / pageSize);
|
||||
if (currentPage > totalPages && totalPages > 0)
|
||||
currentPage = totalPages;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPageChanged(int page) => currentPage = page;
|
||||
|
||||
private string FormatKerf(decimal kerf)
|
||||
{
|
||||
// Show as fraction if it's a common value
|
||||
|
||||
Reference in New Issue
Block a user