diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index 2a8c677fe..4151ecbb2 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -60,7 +60,8 @@ class ProcedurePresentation < ApplicationRecord fields.push( field_hash('user', 'email', type: :text), field_hash('followers_instructeurs', 'email', type: :text), - field_hash('groupe_instructeur', 'id', type: :enum) + field_hash('groupe_instructeur', 'id', type: :enum), + field_hash('avis', 'id', type: :text) ) if procedure.for_individual @@ -246,7 +247,7 @@ class ProcedurePresentation < ApplicationRecord Dossier.human_attribute_name("state.#{filter['value']}") elsif filter['table'] == 'groupe_instructeur' && filter['column'] == 'id' instructeur.groupe_instructeurs - .find { _1.id == filter['value'].to_i }&.label || "Groupe Instucteur #{filter['value']}" + .find { _1.id == filter['value'].to_i }&.label || "Groupe Instructeur #{filter['value']}" else filter['value'] end diff --git a/app/services/dossier_projection_service.rb b/app/services/dossier_projection_service.rb index 1e9de5180..e790ff647 100644 --- a/app/services/dossier_projection_service.rb +++ b/app/services/dossier_projection_service.rb @@ -92,6 +92,14 @@ class DossierProjectionService .group_by { |dossier_id, _| dossier_id } .to_h { |dossier_id, dossier_id_emails| [dossier_id, dossier_id_emails.sort.map { |_, email| email }&.join(', ')] } # rubocop:enable Style/HashTransformValues + when 'avis' + # rubocop:disable Style/HashTransformValues + fields[0][:id_value_h] = Avis + .where(dossier_id: dossiers_ids) + .pluck('dossier_id', 'question_answer') + .group_by { |dossier_id, _| dossier_id } + .to_h { |dossier_id, question_answer| [dossier_id, question_answer.map { |_, answer| answer }&.compact&.tally&.map { |k, v| I18n.t("helpers.label.question_answer.#{k}") + ": #{v}" }&.join(' / ')] } + # rubocop:enable Style/HashTransformValues end end diff --git a/config/locales/models/procedure_presentation/en.yml b/config/locales/models/procedure_presentation/en.yml index 8c46c4965..25f8e1252 100644 --- a/config/locales/models/procedure_presentation/en.yml +++ b/config/locales/models/procedure_presentation/en.yml @@ -28,6 +28,8 @@ en: prenom: First name nom: Last name gender: Title + avis: + id: Opinion etablissement: entreprise_siren: SIREN entreprise_forme_juridique: Forme juridique diff --git a/config/locales/models/procedure_presentation/fr.yml b/config/locales/models/procedure_presentation/fr.yml index 640c1a5a2..08557cd54 100644 --- a/config/locales/models/procedure_presentation/fr.yml +++ b/config/locales/models/procedure_presentation/fr.yml @@ -28,6 +28,8 @@ fr: prenom: Prénom nom: Nom gender: Civilité + avis: + id: Avis etablissement: entreprise_siren: SIREN entreprise_forme_juridique: Forme juridique