Fix three bugs: vendor duplicate check, page size dropdown, label location
- Vendor Create: reject duplicate company names (case-insensitive) before saving; works for both the standalone form and the inline quick-add modal - _Pagination: define changePageSize() JS function (was called but never existed, breaking page size dropdown on every paginated list) - Inventory Label: show bin/location on printed QR code labels Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -215,8 +215,23 @@ public class VendorsController : Controller
|
||||
try
|
||||
{
|
||||
var currentUser = await _userManager.GetUserAsync(User);
|
||||
var companyId = currentUser!.CompanyId;
|
||||
|
||||
var duplicate = await _unitOfWork.Vendors.FirstOrDefaultAsync(
|
||||
v => v.CompanyId == companyId && v.CompanyName.ToLower() == dto.CompanyName.ToLower());
|
||||
if (duplicate != null)
|
||||
{
|
||||
var msg = $"A vendor named '{dto.CompanyName}' already exists.";
|
||||
if (inline)
|
||||
return Json(new { success = false, errors = new[] { msg } });
|
||||
ModelState.AddModelError(nameof(dto.CompanyName), msg);
|
||||
await PopulateExpenseAccountsAsync();
|
||||
await PopulateVendorCategoriesAsync(dto.CategoryIds);
|
||||
return View(dto);
|
||||
}
|
||||
|
||||
var vendor = _mapper.Map<Vendor>(dto);
|
||||
vendor.CompanyId = currentUser!.CompanyId;
|
||||
vendor.CompanyId = companyId;
|
||||
|
||||
if (dto.CategoryIds.Any())
|
||||
{
|
||||
|
||||
@@ -95,6 +95,16 @@
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.label-location {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
background: #f0f0f0;
|
||||
border-radius: 4px;
|
||||
padding: 2px 8px;
|
||||
letter-spacing: .03em;
|
||||
}
|
||||
|
||||
.label-scan-hint {
|
||||
font-size: 9px;
|
||||
color: #888;
|
||||
@@ -158,6 +168,11 @@
|
||||
<div class="label-sku" style="color:#777">@Model.Manufacturer</div>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.Location))
|
||||
{
|
||||
<div class="label-location">📍 @Model.Location</div>
|
||||
}
|
||||
|
||||
<div class="label-scan-hint">
|
||||
Scan to log usage • Powder Coating Logix
|
||||
</div>
|
||||
|
||||
@@ -83,4 +83,12 @@
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function changePageSize(size) {
|
||||
var url = new URL(window.location.href);
|
||||
url.searchParams.set('pageSize', size);
|
||||
url.searchParams.set('pageNumber', '1');
|
||||
window.location.href = url.toString();
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user