apply-for-teacher-training
apply-for-teacher-training copied to clipboard
Refactor references to use DFE wizard
Context
This is a refactor of the references forms. We have 3 places where the user can add a reference. When the user completes his profile(candidate-details
). After accepting an offer(accept-offer
) and when requesting a reference request-reference
.
Previously, the way this was working was with a 'base controller' for example the type_controller and depending on the type of reference it will inherit from this controller. So for the reference after accepting the offer this was the controller inheriting from the normal type_controller
The saving of the references was also done with normal form objects. This PR also introduces DFE wizard to save the references.
I thought about splitting this PR into 2, one for implementing DFE wizard and one for consolidating the controllers but because of the inheritance structure, they cannot be separated, in my view.
If this PR is merged the old controllers and references forms can be removed but that will happen in the next PR.
Changes proposed in this pull request
The routes have been consolidated under /references/:reference_process
where reference process refers to the different type of reference.
The dfe wizard gem has been used to handle the multi step form for every wizard, with 4 steps(type, name, email and relationship). The dfe wizard steps also handle the redirection to the next or previous steps. I didn't use the next_step_path
helper that the dfe wizard provides as I need to specify the paths manually and they need to be more dynamic than the gem allows.
-
candidate-details
the reference that the user adds as a candidate -
accept-offer
the reference the user adds after accepting the offer -
request-reference
the reference the user requests
I have split all the changes into 3 commits to be easier to review.
- Basic DFE wizard and controller refactor
-
Other changes like cancel reference and handling the
accept-offer
reference andrequest-reference
- Specs that needed updating
Guidance to review
Go on the review app and add/remove/cancel all 3 types of references
https://github.com/DFE-Digital/apply-for-teacher-training/assets/11318084/6d5cdd66-7070-41a1-8594-f3fc5cf842b2
Link to Trello card
Things to check
- [ ] If the code removes any existing feature flags, a data migration has also been added to delete the entry from the database
- [x] This code does not rely on migrations in the same Pull Request
- [ ] If this code includes a migration adding or changing columns, it also backfills existing records for consistency
- [ ] If this code adds a column to the DB, decide whether it needs to be in analytics yml file or analytics blocklist
- [ ] API release notes have been updated if necessary
- [ ] If it adds a significant user-facing change, is it documented in the CHANGELOG?
- [ ] Required environment variables have been updated added to the Azure KeyVault