Skip to content

Show exit pages#1261

Merged
thomasiles merged 4 commits intomainfrom
show_exit_pages
Mar 17, 2025
Merged

Show exit pages#1261
thomasiles merged 4 commits intomainfrom
show_exit_pages

Conversation

@thomasiles
Copy link
Copy Markdown
Contributor

@thomasiles thomasiles commented Mar 13, 2025

Add support for exit pages within the runner

Trello card: https://trello.com/c/pfNYulxC/2151-add-support-for-exit-pages-to-forms-runner

Exit pages are given a url like this: "/preview-live/3/branch-route-form/11/exit". "/exit" is added on to the end of the page_slug.

We can change exit to anything else easily, I'll post something in slack and we make the change in another PR. It's just changing the route definition, so shouldn't be hard.

This PR doesn't add events when an exit page is viewed. I'll create another card which captures that so we can discuss what's best with Anne.

image

Note: I mucked up the markdown in the API seed for the exit pages. The above will only show correctly in the preview when the PR for fixing the seed is merged into the API.

Things to consider when reviewing

  • Ensure that you consider the wider context.
  • Does it work when run on your machine?
  • Is it clear what the code is doing?
  • Do the commit messages explain why the changes were made?
  • Are there all the unit tests needed?
  • Has all relevant documentation been updated?

Copy link
Copy Markdown
Contributor

@lfdebrux lfdebrux left a comment

Choose a reason for hiding this comment

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

This is great, really clear breakdown of the commits and helpful commit messages. I've tested locally, it works for me.

To show exit pages to form fillers we need to add a route, controller
and view.

Exit pages are represented by conditions with exit_page_markdown set.

For the route, we use the page slug and add /exit to the URL. This works
because pages can only have one exit page at the moment. We might need
to add condition id or make other changes when pages can have more than
one exit page or when the exit page is the secondary route.

The exit page controller inherits from page because it uses the current
form, mode and step.

We also redirect users back when they cannot view the current step
because they haven't completed the form. The exit page is accessible as
soon as the user can view the question step, regardless of the answer to
the selection question.
Add two helpers which help us identify when a step has a condition which
leads to an exit page.
Exit pages do not route on to other questions in the form when the
condition is met.

To represent this, Step#next_page_slug_after_routing
returns nil when the page matches.

This allows the journey code to stop looking for the next page and
return. Exit page conditions already have a goto_page_id set to nil, so
we could let this value be passed on more implicitly.

Handling the case early clearly shows our intention. Exit_pages don't go
to another page when they have been selected.
Add a feature test for the basic journey of visiting an exit page,
pressing back and changing the answer to complete the form.
@sonarqubecloud
Copy link
Copy Markdown

@thomasiles thomasiles merged commit 14c8309 into main Mar 17, 2025
@thomasiles thomasiles deleted the show_exit_pages branch March 17, 2025 15:19
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