MD.OFFICE
FAL

Daily Log: 2026-03-16

Formula Guards Implementation (Dynaforms)

Achievements & Changes

  • Implemented Hard Guards for Field Type Changes:
    • Modified RightPanelStaticComponent.onNumberTypeChange to block changes to/from Percentage or Currency if the field is referenced in formulas, rules, or validation.
    • Added RightPanelStaticComponent.onCurrencyChange to block currency code changes (e.g., INR to USD) for fields used in formulas.
    • Used cdr.detectChanges() to revert UI state visually when a change is blocked.
  • Enhanced Property Panel UI:
    • Updated right-panel-static.component.html to bind the Currency dropdown to the new guard method.

Decisions

  • Blocking vs Warning: Decided to use a hard block (Error Toast) instead of a warning for currency/percentage changes to prevent silent data interpretation failures.

Dynamic Formula Output Types (Dynaforms)

Achievements & Changes

  • Implemented Runtime Output Type Switching:
    • Updated form-element-config.types.ts to store outputType and outputCurrency per FormulaDefinition.
    • Modified RightPanelStaticComponent to bridge inferred output types into library entries.
    • Updated FormulaFieldComponent (Renderer) to detect active formula types and hot-switch between p-datepicker and p-inputNumber.
  • Edge Case Mitigation:
    • Implemented automatic value clearing (setValue(null)) when the output type switches at runtime.
  • Bug Fixes (PM Update):
    • Race Condition: Swapped emission order in FormulaBuilderComponent to ensure outputType is persistent before a save.
    • Chained Inference: Enhanced suggestion mapping so formulas identify as Dates or Currency when referenced in other formulas.

Decisions

  • Immediate Value Reset: Critical for stability when switching between DatePicker and InputNumber.
  • Emission Ordering: Discovered that saving a formula must happen after the type assertion to ensure state consistency.