diff --git a/CutList.Web/Components/Pages/Jobs/Index.razor b/CutList.Web/Components/Pages/Jobs/Index.razor
index bb6ed96..9efa651 100644
--- a/CutList.Web/Components/Pages/Jobs/Index.razor
+++ b/CutList.Web/Components/Pages/Jobs/Index.razor
@@ -47,7 +47,7 @@ else
- @foreach (var job in jobs)
+ @foreach (var job in pagedJobs)
{
| @job.JobNumber |
@@ -65,6 +65,8 @@ else
}
+
+
}
jobs = new();
private bool loading = true;
private bool creating = false;
+ private int currentPage = 1;
+ private int pageSize = 25;
private ConfirmDialog deleteDialog = null!;
private Job? jobToDelete;
private string deleteMessage = "";
+ private IEnumerable pagedJobs => jobs.Skip((currentPage - 1) * pageSize).Take(pageSize);
+
protected override async Task OnInitializedAsync()
{
jobs = await JobService.GetAllAsync();
@@ -114,9 +120,15 @@ else
{
await JobService.DeleteAsync(jobToDelete.Id);
jobs = await JobService.GetAllAsync();
+
+ var totalPages = (int)Math.Ceiling((double)jobs.Count / pageSize);
+ if (currentPage > totalPages && totalPages > 0)
+ currentPage = totalPages;
}
}
+ private void OnPageChanged(int page) => currentPage = page;
+
private async Task DuplicateJob(Job job)
{
var duplicate = await JobService.DuplicateAsync(job.Id);
diff --git a/CutList.Web/Components/Pages/Materials/Index.razor b/CutList.Web/Components/Pages/Materials/Index.razor
index 6230959..95396d1 100644
--- a/CutList.Web/Components/Pages/Materials/Index.razor
+++ b/CutList.Web/Components/Pages/Materials/Index.razor
@@ -40,19 +40,17 @@ else
Type |
Grade |
Size |
- Description |
Actions |
- @foreach (var material in materials)
+ @foreach (var material in pagedMaterials)
{
| @material.Shape.GetDisplayName() |
@material.Type |
@material.Grade |
@material.Size |
- @material.Description |
Edit
@@ -63,6 +61,8 @@ else
}
|
+
+
}
materials = new();
private bool loading = true;
private string? errorMessage;
+ private int currentPage = 1;
+ private int pageSize = 25;
private ConfirmDialog deleteDialog = null!;
private Material? materialToDelete;
private string deleteMessage = "";
+ private IEnumerable pagedMaterials => materials.Skip((currentPage - 1) * pageSize).Take(pageSize);
+
protected override async Task OnInitializedAsync()
{
try
@@ -108,6 +112,12 @@ else
{
await MaterialService.DeleteAsync(materialToDelete.Id);
materials = await MaterialService.GetAllAsync();
+
+ var totalPages = (int)Math.Ceiling((double)materials.Count / pageSize);
+ if (currentPage > totalPages && totalPages > 0)
+ currentPage = totalPages;
}
}
+
+ private void OnPageChanged(int page) => currentPage = page;
}
diff --git a/CutList.Web/Components/Pages/Stock/Index.razor b/CutList.Web/Components/Pages/Stock/Index.razor
index 674ff7a..3584324 100644
--- a/CutList.Web/Components/Pages/Stock/Index.razor
+++ b/CutList.Web/Components/Pages/Stock/Index.razor
@@ -41,7 +41,7 @@ else
- @foreach (var item in stockItems)
+ @foreach (var item in pagedItems)
{
| @item.Material.Shape.GetDisplayName() |
@@ -69,6 +69,8 @@ else
}
+
+
}
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 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;
}
diff --git a/CutList.Web/Components/Pages/Suppliers/Index.razor b/CutList.Web/Components/Pages/Suppliers/Index.razor
index 379b5f7..eb6dc54 100644
--- a/CutList.Web/Components/Pages/Suppliers/Index.razor
+++ b/CutList.Web/Components/Pages/Suppliers/Index.razor
@@ -31,7 +31,7 @@ else
- @foreach (var supplier in suppliers)
+ @foreach (var supplier in pagedSuppliers)
{
| @supplier.Name |
@@ -47,6 +47,8 @@ else
}
+
+
}
suppliers = new();
private bool loading = true;
+ private int currentPage = 1;
+ private int pageSize = 25;
private ConfirmDialog deleteDialog = null!;
private Supplier? supplierToDelete;
private string deleteMessage = "";
+ private IEnumerable pagedSuppliers => suppliers.Skip((currentPage - 1) * pageSize).Take(pageSize);
+
protected override async Task OnInitializedAsync()
{
suppliers = await SupplierService.GetAllAsync();
@@ -81,9 +87,15 @@ else
{
await SupplierService.DeleteAsync(supplierToDelete.Id);
suppliers = await SupplierService.GetAllAsync();
+
+ var totalPages = (int)Math.Ceiling((double)suppliers.Count / pageSize);
+ if (currentPage > totalPages && totalPages > 0)
+ currentPage = totalPages;
}
}
+ private void OnPageChanged(int page) => currentPage = page;
+
private string? TruncateText(string? text, int maxLength)
{
if (string.IsNullOrEmpty(text) || text.Length <= maxLength)
diff --git a/CutList.Web/Components/Pages/Tools/Index.razor b/CutList.Web/Components/Pages/Tools/Index.razor
index 21b3e4c..49420da 100644
--- a/CutList.Web/Components/Pages/Tools/Index.razor
+++ b/CutList.Web/Components/Pages/Tools/Index.razor
@@ -78,7 +78,7 @@ else
- @foreach (var tool in tools)
+ @foreach (var tool in pagedTools)
{
| @tool.Name |
@@ -97,6 +97,8 @@ else
}
+
+
}
}
@@ -112,6 +114,10 @@ else
private bool showForm;
private bool saving;
private string? errorMessage;
+ private int currentPage = 1;
+ private int pageSize = 25;
+
+ private IEnumerable 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