Files
CutList/CutList.Web/Components/Pages/Stock/Index.razor
AJ Isaacs b0a9d7fdcc docs: Add descriptive intro text to index pages
Adds brief explanatory paragraphs to Jobs, Materials, and Stock index
pages to help users understand each section's purpose.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-05 23:17:53 -05:00

109 lines
3.4 KiB
Plaintext

@page "/stock"
@inject StockItemService StockItemService
@inject NavigationManager Navigation
@using CutList.Core.Formatting
@using CutList.Web.Data.Entities
<PageTitle>Stock Items</PageTitle>
<div class="d-flex justify-content-between align-items-center mb-3">
<h1>Stock Items</h1>
<a href="stock/new" class="btn btn-primary">Add Stock Item</a>
</div>
<p class="text-muted mb-4">
Stock items represent the specific lengths of material you have available for cutting. Each stock item links
a material to a length and tracks how many pieces you have on hand.
</p>
@if (loading)
{
<p><em>Loading...</em></p>
}
else if (stockItems.Count == 0)
{
<div class="alert alert-info">
No stock items found. <a href="stock/new">Add your first stock item</a>.
</div>
}
else
{
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Shape</th>
<th>Type</th>
<th>Grade</th>
<th>Size</th>
<th>Length</th>
<th>On Hand</th>
<th style="width: 160px;">Actions</th>
</tr>
</thead>
<tbody>
@foreach (var item in stockItems)
{
<tr>
<td>@item.Material.Shape.GetDisplayName()</td>
<td>@item.Material.Type</td>
<td>@item.Material.Grade</td>
<td>@item.Material.Size</td>
<td>@ArchUnits.FormatFromInches((double)item.LengthInches)</td>
<td>
@if (item.QuantityOnHand > 0)
{
<span class="badge bg-success">@item.QuantityOnHand</span>
}
else
{
<span class="badge bg-secondary">0</span>
}
</td>
<td>
<div class="d-flex gap-1">
<a href="stock/@item.Id" class="btn btn-sm btn-outline-primary">Edit</a>
<button class="btn btn-sm btn-outline-danger" @onclick="() => ConfirmDelete(item)">Delete</button>
</div>
</td>
</tr>
}
</tbody>
</table>
}
<ConfirmDialog @ref="deleteDialog"
Title="Delete Stock Item"
Message="@deleteMessage"
ConfirmText="Delete"
OnConfirm="DeleteConfirmed" />
@code {
private List<StockItem> stockItems = new();
private bool loading = true;
private ConfirmDialog deleteDialog = null!;
private StockItem? itemToDelete;
private string deleteMessage = "";
protected override async Task OnInitializedAsync()
{
stockItems = await StockItemService.GetAllAsync();
loading = false;
}
private void ConfirmDelete(StockItem item)
{
itemToDelete = item;
deleteMessage = $"Are you sure you want to delete \"{item.Material.DisplayName} - {ArchUnits.FormatFromInches((double)item.LengthInches)}\"?";
deleteDialog.Show();
}
private async Task DeleteConfirmed()
{
if (itemToDelete != null)
{
await StockItemService.DeleteAsync(itemToDelete.Id);
stockItems = await StockItemService.GetAllAsync();
}
}
}