MD.OFFICE
FAL

Daily Log — 2026-02-23

FormulaBuilderComponent — Extraction Finalization & Dead Code Cleanup

Dead Code Removed from right-panel-static

  • Removed properties: formulaInput, formulaMessage, isFormulaValid, editingFormulaInput, operators + OPERATORS import.
  • Removed methods: onFormulaValidationResult(), toValueFormula().
  • Removed all stale writes to this.formulaMessage = '' and this.formulaInput = ... in createNewFormula, editFormulaInLibrary, cancelFormulaEdit.
  • Removed (validationResult) output bindings from both <app-formula-builder> template instances.
  • Verified build passes after all removals.

hasError Input Added Then Consolidated

  • Initially added @Input() hasError to pass __isFormulaError for red border display.
  • Later consolidated into a single @Input() errorMessage — presence of text drives both the red border and the error display. Removed hasError entirely.

FormulaBuilderComponent — Error Handling Refinement & Cleanup

Error Message Moved Into Builder

  • Moved the __formulaError text (e.g. "Formula not configured") from the right-panel template into FormulaBuilderComponent via a new @Input() errorMessage input.
  • Error text is now displayed inside the builder, alongside the validation message (formulaMessage), keeping all formula-related messaging in one place.
  • Removed the standalone <small *ngIf="selectedItem?.__isFormulaError"> block from right-panel-static.component.html.

hasError Input Removed

  • Consolidated hasError (boolean) and errorMessage (string) into just errorMessage. The red border condition now uses errorMessage || (!isFormulaValid && formulaMessage) — the presence of errorMessage text is sufficient to derive both the border and the text display.
  • Removed [hasError] bindings from both app-formula-builder instances in the right-panel template.

Library Editor Now Receives Error State

  • Both builder instances (main tab and formula editor tab) now receive [errorMessage]="selectedItem?.__formulaError || ''", since a formula field needs either a configured formula or at least one default formula when useRules is true.

Validation Message Persistence Bug — Fixed

  • Bug: "Formula is valid" message disappeared on first validate click. Root cause: successful validation emits formulaChange → parent saves selectedItem.formula[formulaValue] changes → ngOnChanges reset the message.
  • Fix: Added lastEmittedFormula tracking. On successful validation, the emitted formula is stored. When the setter detects the incoming value matches lastEmittedFormula, it skips the validation state reset.

Refactored formulaValue to Input Setter (replaces ngOnChanges)

  • Replaced ngOnInit + ngOnChanges with @Input() set formulaValue() getter/setter pattern.
  • Why: ngOnChanges fires for all input changes and requires manual filtering via string-based property lookups. The setter only fires for formulaValue, is type-safe, handles both initial bind and subsequent changes in one place, and scales better as more reactive inputs are added.
  • Removed SimpleChanges import (no longer needed).

Files Changed

  • formula-builder.component.ts — Added errorMessage input, lastEmittedFormula tracking, refactored to input setter, removed ngOnChanges/ngOnInit/SimpleChanges
  • formula-builder.component.html — Added errorMessage display, updated red border ngClass condition to use errorMessage instead of hasError
  • right-panel-static.component.html — Removed [hasError] bindings, added [errorMessage] to both builder instances, removed standalone error <small>