From bb236f6c0d2703f51d353bb9952a6d01d80aab7e Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Tue, 30 Jan 2024 10:56:57 +0100 Subject: [PATCH] fix duplication text for tiers in instructeur table --- app/services/dossier_projection_service.rb | 15 +++++++++++++-- app/views/instructeurs/procedures/show.html.haml | 4 ---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/services/dossier_projection_service.rb b/app/services/dossier_projection_service.rb index 67a8d928c..d2e3612e4 100644 --- a/app/services/dossier_projection_service.rb +++ b/app/services/dossier_projection_service.rb @@ -14,6 +14,15 @@ class DossierProjectionService end end + def self.for_tiers_translation(array) + for_tiers, email, first_name, last_name = array + if for_tiers == true + "#{email} #{I18n.t('views.instructeurs.dossiers.acts_on_behalf')} #{first_name} #{last_name}" + else + email + end + end + TABLE = 'table' COLUMN = 'column' @@ -82,11 +91,13 @@ class DossierProjectionService .pluck(:dossier_id, *fields.map { |f| f[COLUMN].to_sym }) .each { |id, *columns| fields.zip(columns).each { |field, value| field[:id_value_h][id] = value } } when 'user' + fields[0][:id_value_h] = Dossier # there is only one field available for user table .joins(:user) + .includes(:individual) .where(id: dossiers_ids) - .pluck('dossiers.id, users.email') - .to_h + .pluck('dossiers.id, dossiers.for_tiers, users.email, individuals.prenom, individuals.nom') + .to_h { |dossier_id, *array| [dossier_id, for_tiers_translation(array)] } when 'groupe_instructeur' fields[0][:id_value_h] = Dossier .joins(:groupe_instructeur) diff --git a/app/views/instructeurs/procedures/show.html.haml b/app/views/instructeurs/procedures/show.html.haml index 9664dff67..0028c2cda 100644 --- a/app/views/instructeurs/procedures/show.html.haml +++ b/app/views/instructeurs/procedures/show.html.haml @@ -164,10 +164,6 @@ %span.cell-link = column = "- #{t('views.instructeurs.dossiers.deleted_by_user')}" if p.hidden_by_user_at.present? - - elsif p.for_tiers - %a.cell-link{ href: path } - = "#{column} (#{t('views.instructeurs.dossiers.acts_on_behalf')} #{p.prenom} #{p.nom})" - = "- #{t('views.instructeurs.dossiers.deleted_by_user')}" if p.hidden_by_user_at.present? - else %a.cell-link{ href: path } = column