Skip to content

feat(launchpad): build widget-calculated-fields - #1246

Merged
rubenvdlinde merged 4 commits into
developmentfrom
quality/build-widget-calculated-fields
Nov 16, 2026
Merged

rubenvdlinde merged 4 commits into
developmentfrom
quality/build-widget-calculated-fields

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Continues widget-calculated-fields after #1233 (merged): the dashboard-side evaluation, display formatting and server-side cycle detection.

Tasks done

  • 13, 17, 18: evaluateDashboard() (src/utils/calculatedFields/dashboardValues.js) evaluates every calculated field of a dashboard in the cycle detector's topological order and gives each field the other widgets' current data and calculated values. A failing field yields null plus an inline error {error, expression, inputs}, and the rest of the dashboard still evaluates. Widgets in a cycle get the cycle error on each of their fields. dependentWidgets() names the widgets a data change reaches. The new Pinia store src/stores/calculatedFields.js (setWidgets, setWidgetData, setFilters, valuesOf, errorsOf) re-evaluates on every change. useCalculatedFields() watches a widget's data and the filters and returns {values: Map, errors: Map}. The app has no useDashboardsStore.js, so this is its own store.
  • 34, 36 (35 in part): formatOptions.js covers number/currency (Intl.NumberFormat), dates (Intl.DateTimeFormat, UTC by default) and duration patterns (d, h, m, s, with literals in quotes). It returns display strings only, so values stay native for alerting and export.
  • 23 (in part), 40 (in part): CalculatedFieldCycleDetector.php and CalculatedFieldCycleError.php port the client cycle detector node for node: same order, same cycleDetected envelope.
  • 50, 51: SPDX headers checked; changelog entry added.

Tasks left and why

  • 19, 20, 35 (renderers): the widget renderers still have to call the store and the formatters, and show the inline error icon.
  • 21, 22: calculatedFields storage on the placement. 23-25, 37: a PHP AST type check, validateAndCompile, and the 400 envelopes on save. Each needs the storage first.
  • 26-29, 32, 39: OpenRegister materialisation and downgrade.
  • 41, 44-46: parser tests are already ≥100 cases in parser.spec.js; the Playwright tasks need a live instance and are left for that.
  • 47-49, 52, 53: final quality, API docs, i18n, design write-up and gates, once the feature is complete.

Tests added

  • Vitest: dashboardValues.spec.js (11), formatOptions.spec.js (14), useCalculatedFields.spec.js (5). Each was checked to fail with its subject line broken.
  • PHPUnit: CalculatedFieldCycleDetectorTest (7).

Suite before/after

  • Vitest: 2586 → 2616, 0 failures.
  • PHPUnit: 4498 on this branch (development merged in), 0 failures, 13 skipped.
  • phpcs and phpstan are clean on the new PHP files; eslint is clean on the new JS files.

Generated by Claude Code

Dashboard-wide evaluation of calculated fields in topological order with
cross-widget references (tasks 13, 17, 18): evaluateDashboard(), a
calculated-fields Pinia store and the useCalculatedFields() composable.
Format options applied at display time only (tasks 34, 36; 35 in part).

Assisted-by: ClaudeCode
Server-side cycle detection mirroring the client detector (task 23 in
part, task 40 in part), changelog entry (51), SPDX check (50).

Assisted-by: ClaudeCode
…units [skip ci]

Restores the unit-complexity rating: every new function now has a
cyclomatic complexity of 5 or less. Behaviour is unchanged.

Assisted-by: ClaudeCode:claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant