diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 437289791..8a28e937c 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -556,18 +556,22 @@ module Users def update_dossier_and_compute_errors @dossier.update_champs_attributes(champs_public_attributes_params, :public, updated_by: current_user.email) - if @dossier.champs.any?(&:changed_for_autosave?) + updated_champs = @dossier.champs.filter(&:changed_for_autosave?) + if updated_champs.present? @dossier.last_champ_updated_at = Time.zone.now - - if @dossier.champs_public.any? { _1.changed_for_autosave? && _1.used_by_routing_rules? } - RoutingEngine.compute(@dossier) - end end # We save the dossier without validating fields, and if it is successful and the client # requests it, we ask for field validation errors. - if @dossier.save && params[:validate].present? - @dossier.valid?(:champs_public_value) + if @dossier.save + if updated_champs.any?(&:used_by_routing_rules?) + @update_contact_information = true + RoutingEngine.compute(@dossier) + end + + if params[:validate].present? + @dossier.valid?(:champs_public_value) + end end @dossier.errors diff --git a/app/views/users/dossiers/update.turbo_stream.haml b/app/views/users/dossiers/update.turbo_stream.haml index 7a6d13108..b2ebd2205 100644 --- a/app/views/users/dossiers/update.turbo_stream.haml +++ b/app/views/users/dossiers/update.turbo_stream.haml @@ -5,5 +5,6 @@ = turbo_stream.append('contenu', render(Dossiers::InvalidIneligibiliteRulesComponent.new(dossier: @dossier))) - else @ineligibilite_rules_is_computable = turbo_stream.remove(dom_id(@dossier, :ineligibilite_rules_broken)) -- if @dossier.champs.any? { _1.used_by_routing_rules? && params[:dossier][:champs_public_attributes].key?(_1.stable_id.to_s) } + +- if @update_contact_information = turbo_stream.update "contact_information", partial: 'shared/dossiers/update_contact_information', locals: { dossier: @dossier, procedure: @procedure }