Merge pull request #9950 from demarches-simplifiees/fix-duplication-text-for-tiers-in-instructeur-table

Instructeur: corrige une redondance de texte dans le tableau quand un dossier est pour un tiers
This commit is contained in:
Lisa Durand 2024-01-31 10:18:27 +00:00 committed by GitHub
commit 3c57b64b1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 6 deletions

View file

@ -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)

View file

@ -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