Fix custom formula wizard bugs and add field name validation
- Fix Add Field blanking inputs: cfFields was IIFE-scoped so inline oninput handlers couldn't reach it; expose cfUpdateField on window - Fix ManualUnitPrice dropped in buildItemFromData: condition excluded isCustomFormulaItem, causing FixedRate items to reprice from scratch - Fix formula card missing on job pages: load CustomFormulaTemplates in PopulateJobItemDropDownsAsync so Details, EditItems, and Edit all get it; add customFormulaTemplates + formulaEvalUrl to Details and EditItems pageMeta - Add NCalc field name validation: client-side inline feedback (is-invalid + message on oninput) and pre-save sweep; server-side ValidateTemplateFields on Create and Update; rules: letter-start, letters/digits/underscores only, no duplicates, "rate" reserved Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3340,6 +3340,13 @@ public class JobsController : Controller
|
||||
var useMetric = await _tenantContext.UseMetricSystemAsync();
|
||||
ViewBag.UseMetric = useMetric;
|
||||
ViewBag.AreaUnit = _measurementService.GetAreaUnitLabel(useMetric);
|
||||
|
||||
var formulaTemplates = await _unitOfWork.CustomItemTemplates.FindAsync(t => t.CompanyId == companyId && t.IsActive);
|
||||
ViewBag.CustomFormulaTemplates = formulaTemplates.OrderBy(t => t.DisplayOrder).ThenBy(t => t.Name)
|
||||
.Select(t => new { id = t.Id, name = t.Name, description = t.Description, outputMode = t.OutputMode,
|
||||
fieldsJson = t.FieldsJson, formula = t.Formula, defaultRate = t.DefaultRate, rateLabel = t.RateLabel,
|
||||
diagramImagePath = string.IsNullOrEmpty(t.DiagramImagePath) ? null
|
||||
: Url.Action("TemplateDiagram", "CompanySettings", new { templateId = t.Id }) }).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user