feat(editor): datatype-driven scenario parameter inputs#748
Open
tdjager wants to merge 1 commit into
Open
Conversation
0e8a585 to
9ff7bc1
Compare
Scenario parameter inputs always rendered as a text field regardless of
the parameter's declared datatype. Add a generic ScenarioParameterInput
control that renders the matching NDD component per datatype:
- boolean -> nldd-switch-field (consistent with EditSheet)
- number -> nldd-number-field
- amount -> nldd-number-field, unit-aware (eurocent shows euros / stores
eurocents via shared currency helpers; otherwise raw number)
- date -> nldd-text-field type=date
- string -> nldd-text-field (fallback)
buildTypeMap() resolves each parameter's type+unit from the law's
execution.parameters/input; ScenarioBuilder threads it into ScenarioForm.
Extract centsToEuros/eurosToCents into utils/currency.js (reused by
EditSheet). Values are coerced to real JS types and round-trip cleanly
through formMapper/parseValue.
The calculation-date field reuses the same control.
5dca077 to
8f90816
Compare
Preview Deployment — editor — editorYour changes have been deployed to a preview environment: URL: https://editor.pr748.rig.prd1.gn2.quattro.rijksapps.nl This deployment will be automatically cleaned up when the PR is closed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Scenario parameter inputs in the editor always rendered as a plain text field, regardless of the parameter's declared datatype — so a boolean was typed as the literal text
true, an amount as a raw number, a date as a free-text string.This adds a generic, datatype-driven control (
ScenarioParameterInput.vue) that renders the NDD component matching each parameter's declared datatype:booleannldd-switch-field(consistent with EditSheet)numbernldd-number-fieldamountnldd-number-field, unit-awaredatenldd-text-field type="date"stringnldd-text-field(fallback)The "Datum" (calculation date) field reuses the same control.
How it works
buildTypeMap(articles)(new, sibling ofbuildArticleMap) resolves each parameter's{ type, unit }from the law'sexecution.parameters/execution.input.ScenarioBuilderthreads it intoScenarioForm.formMapper/parseValue(verified by test) — noformMapperchange needed.type_spec.unit: eurocent, the user enters euros and the value is stored as integer eurocents (e.g.150000⇄1500); withunit: euroor no declared unit it stays a raw number, so we never silently scale a value whose unit we don't know. The euro⇄eurocent math is extracted intoutils/currency.jsand reused byEditSheet.Stacked on #729
This builds on #729 (RFC-019, units of measurement), which adds
type_spec.unittoparameterField— that's what makes the amount control's unit-awareness real rather than dormant. Base this PR's merge on #729; once #729 lands, rebase ontomain.Parameters without a declared unit fall back to a raw number-field, so un-annotated laws keep working unchanged.
Tests
currency,buildTypeMap,ScenarioParameterInput(control selection + display/emit coercion per type), and a typedformMapperround-trip — all green (247 frontend tests pass).e2e/scenario-param-inputs.spec.jsopens a scenario with a boolean / amount-eurocent / string parameter and asserts each renders the right control (switch checked, number-field showing1500euros, text-field).Custom CSS
None. Only NDD design-system components; no
<style>added.