Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning when user is about to delete condition with secondary skip #1752

Merged

Conversation

lfdebrux
Copy link
Member

@lfdebrux lfdebrux commented Feb 6, 2025

What problem does this pull request solve?

Trello card: https://trello.com/c/qcaW0Bv1/2107-add-a-warning-to-the-delete-route-page-that-shows-when-there-is-a-secondary-skip-route-for-the-same-question

Currently (when branching is enabled) deleting a skip route for a question that has a secondary skip route puts the form in a state where there is a route with an error that can’t be deleted.

We do want users to be able to delete individual routes for a question.

So we’ve agreed that we will delete the secondary skip for a question when deleting any other routes for that question. And we’ll let the user know before the delete a route, with a warning.

This PR does some refactoring and adds the warning; note that the deletion will take place in forms-api, see alphagov/forms-api#686.

Screenshots

Screenshot of confirmation page for deleting a route with warning about route for any other answer being deleted

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?

@hannahkc
Copy link
Contributor

hannahkc commented Feb 6, 2025

Content in the banner looks good! thanks!

@lfdebrux lfdebrux force-pushed the ldeb-add-warning-deleting-condition-with-secondary-skip branch 2 times, most recently from 3d674cf to 5e86014 Compare February 7, 2025 16:34
- Don't mock DeleteConditionInput object in request specs
- Delegate to condition record rather than requiring caller to unpack
- Add spec for validation errors
Currently (when branching is enabled) deleting a skip route for a
question that has a secondary skip route puts the form in a state where
there is a route with an error that can’t be deleted.

We do want users to be able to delete individual routes for a question.

So we’ve agreed that we will delete the secondary skip for a question
when deleting any other routes for that question. And we’ll let the user
know before the delete a route, with a warning.

This commit adds the warning; note that the deletion will take place in
forms-api, see alphagov/forms-api#686. To enable this we add a method
`#has_secondary_skip?` to the DeleteConfirmationInput object... I'm not
sure if this is the best place for this, but it'll do for now.
@lfdebrux lfdebrux force-pushed the ldeb-add-warning-deleting-condition-with-secondary-skip branch from 5e86014 to 08dec01 Compare February 10, 2025 13:50
Copy link

Copy link
Contributor

@jamie-o-wilkinson jamie-o-wilkinson left a comment

Choose a reason for hiding this comment

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

Chatted this through with @lfdebrux, all looks good to me. Thanks for the explanation and context 👍

@lfdebrux lfdebrux merged commit e06c37e into main Feb 10, 2025
4 checks passed
@lfdebrux lfdebrux deleted the ldeb-add-warning-deleting-condition-with-secondary-skip branch February 10, 2025 14:09
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.

3 participants