From e413c0881e16a5901c02e20c25dffd008c08672d Mon Sep 17 00:00:00 2001 From: Eric Leroy-Terquem Date: Fri, 14 Jun 2024 10:52:33 +0200 Subject: [PATCH] chore(routing): update turbo stream only if champ used by routing rules has been updated --- app/controllers/users/dossiers_controller.rb | 2 +- app/views/users/dossiers/update.turbo_stream.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/users/dossiers_controller.rb b/app/controllers/users/dossiers_controller.rb index 1100119af..437289791 100644 --- a/app/controllers/users/dossiers_controller.rb +++ b/app/controllers/users/dossiers_controller.rb @@ -559,7 +559,7 @@ module Users if @dossier.champs.any?(&:changed_for_autosave?) @dossier.last_champ_updated_at = Time.zone.now - if @dossier.champs_public.filter(&:changed_for_autosave?).any?(&:used_by_routing_rules?) + if @dossier.champs_public.any? { _1.changed_for_autosave? && _1.used_by_routing_rules? } RoutingEngine.compute(@dossier) end end diff --git a/app/views/users/dossiers/update.turbo_stream.haml b/app/views/users/dossiers/update.turbo_stream.haml index 20aff6d9e..7a6d13108 100644 --- a/app/views/users/dossiers/update.turbo_stream.haml +++ b/app/views/users/dossiers/update.turbo_stream.haml @@ -5,5 +5,5 @@ = turbo_stream.append('contenu', render(Dossiers::InvalidIneligibiliteRulesComponent.new(dossier: @dossier))) - else @ineligibilite_rules_is_computable = turbo_stream.remove(dom_id(@dossier, :ineligibilite_rules_broken)) - -= turbo_stream.update "contact_information", partial: 'shared/dossiers/update_contact_information', locals: { dossier: @dossier, procedure: @procedure } +- if @dossier.champs.any? { _1.used_by_routing_rules? && params[:dossier][:champs_public_attributes].key?(_1.stable_id.to_s) } + = turbo_stream.update "contact_information", partial: 'shared/dossiers/update_contact_information', locals: { dossier: @dossier, procedure: @procedure }