[Tech] Refactor Agents RDV creation wizard
Created by: adipasquale
This PR refactors into quite some depth the current agent's RDV wizard before diving into this ticket that will make changes to this wizard.
The reasons for this refactor are :
- the routes didn't feel very nice semantically
- there was quite a lot of code duplication in the controllers
- it should be slightly easier now to make changes to this wizard (reorder steps / change validations)
- I personnally dislike having non-AR models mixed with the other actual AR models
Changes:
-
app/controllers/agents/rdvs/first_steps_controller.rb
, second and third get all merged into a singleapp/controllers/agents/rdv_wizard_steps_controller.rb
- the different step views move from
app/views/agents/rdvs/first_steps/new.html.slim
toapp/views/agents/rdv_wizard_steps/step1.html.slim
and so on - the last step of the wizard's form used to point to
Agents::Rdvs::ThirdStepsController#create
, it now points toAgents::RdvsController#create
which feels more semantically correct - the
app/models/rdv/first_step.rb
, second and third get all merged into a singleapp/form_models/rdv_wizard.rb
object. this is inspired by https://medium.com/@nicolasblanco/developing-a-wizard-or-multi-steps-forms-in-rails-d2f3b7c692ce - this form model object is very much refactored and tries to delegate even more to the underlying
Rdv
AR model. TheRdv#to_step_params
method is deprecated and removed
as a reminder, here are the 3 steps of the RDV wizard
Step 1:
Step 2 :