Skip to content

Add ReviewPresenter and improve wizard internals (state store and steps methods)#11

Merged
tomas-stefano merged 7 commits intomainfrom
feature/review-presenter-and-improvements
Feb 5, 2026
Merged

Add ReviewPresenter and improve wizard internals (state store and steps methods)#11
tomas-stefano merged 7 commits intomainfrom
feature/review-presenter-and-improvements

Conversation

@tomas-stefano
Copy link
Copy Markdown
Collaborator

  1. Add ReviewPresenter module for building Check Your Answers pages

    • Row objects with label, value, formatted_value, and change_path
    • format_value override for custom value formatting
    • Automatic I18n label lookup
  2. Replace StateStore method_missing with explicit attribute accessors

    • Generate reader methods dynamically after wizard initialisation
    • Clearer error messages for undefined attributes
  3. Fix Graph max_depth to use actual step count instead of hardcoded 20

    • Prevents infinite loops on circular graphs
    • Uses @registry.nodes.size for accurate depth limit
  4. Add predicate_caller option to Graph.draw

    • Allows predicates to be called on state_store instead of wizard
    • Cleaner separation of concerns
  5. Add cycle detection tests for circular wizard graphs

1. Add ReviewPresenter module for building Check Your Answers pages
   - Row objects with label, value, formatted_value, and change_path
   - format_value override for custom value formatting
   - Automatic I18n label lookup

2. Replace StateStore method_missing with explicit attribute accessors
   - Generate reader methods dynamically after wizard initialisation
   - Clearer error messages for undefined attributes

3. Fix Graph max_depth to use actual step count instead of hardcoded 20
   - Prevents infinite loops on circular graphs
   - Uses @registry.nodes.size for accurate depth limit

4. Add predicate_caller option to Graph.draw
   - Allows predicates to be called on state_store instead of wizard
   - Cleaner separation of concerns

5. Add cycle detection tests for circular wizard graphs
@tomas-stefano tomas-stefano changed the title Add ReviewPresenter and improve wizard internals Add ReviewPresenter and improve wizard internals (state store and steps methods) Feb 4, 2026
- Rename module to align with GOV.UK Design System terminology
- Add reviewable_steps method (defaults to flow_steps, overridable)
- Add find_reviewable_step to find step by ID from reviewable steps
- row_for now returns nil if step not in reviewable_steps or
  attribute does not exist (enables .compact pattern)
- rows_for returns empty array if step not in reviewable_steps
- Update example presenter and view to use new pattern
- Remove manual in_flow? checks since row_for handles it now
It is not needed anymore after defining the step attributes
as accessors on state store
Copy link
Copy Markdown
Contributor

@avinhurry avinhurry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few thoughts/comments in line.

Nice improvement overall. Moving predicates to state_store is a good step forward.

@tomas-stefano tomas-stefano merged commit f0c589c into main Feb 5, 2026
1 check passed
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.

2 participants