Skip to content

wip(settings): formula fields JSON-first base and preview#14

Draft
akira69 wants to merge 6 commits intomasterfrom
wip/formula-fields-json-first
Draft

wip(settings): formula fields JSON-first base and preview#14
akira69 wants to merge 6 commits intomasterfrom
wip/formula-fields-json-first

Conversation

@akira69
Copy link
Copy Markdown
Owner

@akira69 akira69 commented Mar 29, 2026

Summary

This PR establishes the JSON-first foundation for Formula Extra Fields.

Intent

  • Keep formula authoring centered on the raw JSON Logic editor, preview/sample-values workflow, and save/reopen flow.
  • Provide searchable references, operators, and helpers as lookup and copy aids for manual JSON authoring.
  • Keep the supported reference surface explicit: current-entity built-ins, current-entity extra.<key> fields, and built-in related-entity references.
  • Preserve dependency visibility and delete protection in the Extra Fields table so formula rollout remains reviewable and safe.

Review Focus

  • Does the JSON-first workflow make authoring and validation clear?
  • Are the reference aids useful without turning this PR into a guided-builder flow?
  • Do the table protections and field-link visibility support safe adoption?
  • Does the help text consistently reinforce the JSON-first mental model?

Screenshots

Settings view:

PR14 settings view

Formula editor view:

PR14 editor view

Validation

Commands:

  • uv run ruff check spoolman/derived_fields.py spoolman/extra_fields.py spoolman/formula_references.py spoolman/api/v1/field.py spoolman/api/v1/spool.py spoolman/api/v1/filament.py spoolman/api/v1/vendor.py tests_integration/tests/fields/test_derived.py tests_integration/tests/fields/test_derived_api.py
  • ./node_modules/.bin/eslint src/pages/help/index.tsx src/pages/settings/formulaFieldsSettings.tsx src/pages/settings/extraFieldsSettings.tsx
  • VITE_APIURL=/api/v1 npm run build

Browser validation on http://localhost:1885:

  • Opened Settings -> Extra Fields -> Spools
  • Verified the Extra Fields table shows referenced formula keys as code links and disables delete for referenced custom fields
  • Created a formula field review_json_test with JSON {"date_only":[{"var":"registered"}]}
  • Verified sample values were scaffolded and preview returned derived.review_json_test = 2026-01-01
  • Saved the formula field and confirmed it persisted in the table
  • Reopened the saved formula field for editing
  • Verified the reference-aid area is JSON-first, searchable, and copy-assist oriented
  • Loaded /help#formula-fields and checked the help page text matches the JSON-first scope

Test Checklist

  • Formula field create flow
  • Preview/sample-values flow
  • Save and reopen flow
  • Extra Fields dependency/delete protection
  • Help page copy review
  • Frontend lint
  • Frontend production build with VITE_APIURL=/api/v1
  • Backend/static Ruff check for formula-field files

Follow-up

This PR is intentionally scoped to the JSON-first foundation. Guided insertion and compatibility-driven authoring are handled in stacked PR #13.

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