Skip to content

Hidden enum values#628

Open
zaucker wants to merge 6 commits into
oposs:mainfrom
zaucker:HiddenEnumValues
Open

Hidden enum values#628
zaucker wants to merge 6 commits into
oposs:mainfrom
zaucker:HiddenEnumValues

Conversation

@zaucker
Copy link
Copy Markdown
Contributor

@zaucker zaucker commented May 9, 2026

To handle using the same dataset on both 6.5.2 and 7.0.0 model versions, we have to map free_range enums from Livestock::Poultry::Grazing

This PR marks mapped values in orange, but does not block calculation. Upon storing a new value in the currently opened model, the orange marker goes away.

zaucker and others added 6 commits May 8, 2026 18:50
Two model versions can now share a dataset even when their enum option
sets diverge. A foreign-version value is accepted by the validator,
rewritten to the canonical local key when formulas evaluate, and
surfaced in the GUI as orange (mapped) — informational only, never
blocks calculation.

Backend
- LanguageParser: parse `accepts = a, b, c` inside an enum option as
  a comma-separated alias list, preserving underscores.
- Model::Input: store %!enum-aliases; add canonical-enum-value,
  is-mapped-enum-value, and extend is-valid-enum-value to accept
  aliases. Expose `:enumAliases` via as-hash for the frontend.
- Model::Module: canonicalize-input-hash rewrites alias values to
  the local key for formula evaluation only — storage stays raw, so
  re-opening in the other version still sees its own value.
- Model + Inputs: call canonicalize-input-hash at the two formula-eval
  entry points (run-as-single, apply-defaults).
- t/enum-aliases.rakutest + t/test-data/EnumAliases.nhd: 14 tests
  covering parser, validator, canonical lookup, and module rewrite.

Frontend
- NavFolder: track __mapped per folder and aggregate up the tree.
  Icon precedence: red (incomplete) > orange (mapped) > green
  (complete). Mapped does not gate the outputEnabled event.
- PropTable: extend the cell-renderer replaceMap so a stored alias
  value renders with the canonical option's localized label.
- cellrenderer/input/Replace: orange cell background (#f9d8a4 /
  #fbeacb) when the value is in enumAliases.
- orange-dot.png + orange-circle.png: new 18x18 icons matching the
  existing red/green set.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The frontend's setData() guarded against unknown enum values in the
loaded dataset by alerting "no match for >X< in >a,b,c<, should be
removed from dataset" and dispatching deleteInstanceData. That gate
ran before any of the alias display machinery added in 9508f66, so
a foreign-version value declared as `accepts =` in the .nhd was
purged at load time even though the backend validator and the cell
renderer already understood it.

Treat enumAliases membership as "found" — the value passes through
to setValue unchanged (storage stays raw, preserving round-trip);
the existing replaceMap entries handle the canonical-label render
and the orange highlight.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Without SOURCE_MODE, Cro's static-content routes serve from public/ —
the production build target, which lags behind any source change until
a full minified rebuild runs. With SOURCE_MODE=1 the same routes serve
from frontend/compiled/source/, so a single `npx qx compile` (or live
`--watch`) is enough to see edits in the browser. Matches the dev
workflow the rest of this branch was designed for.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
NavBar.__getInputVariables walks the JSON returned from
getInputVariables and constructs each Variable's metaData. The enum
branch copied only options and optionsLang, dropping the enumAliases
map served alongside. Result: every downstream check
(metaData.enumAliases.hasOwnProperty(value) in NavFolder.setData,
NavFolder.isComplete, the Replace cell renderer, the PropTable
replaceMap) saw `undefined` and short-circuited — so a stored alias
value was rejected at load with "no match for >X< in >a,b,c<, should
be removed from dataset" even though the rest of the alias machinery
was wired up correctly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The cell-editor factory iterates every metaData key and falls into
"This should not happen: unknown metaData value: X" on anything not
explicitly cased. enumAliases is consumed by the renderer and by
NavFolder, so the editor itself has nothing to do — just acknowledge
the key.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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