display avis_anwser yes/no in table

This commit is contained in:
Lisa Durand 2023-04-20 11:44:35 +02:00
parent 7c4ae3b786
commit 65730bcfcb
4 changed files with 15 additions and 2 deletions

View file

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

View file

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

View file

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

View file

@ -28,6 +28,8 @@ fr:
prenom: Prénom
nom: Nom
gender: Civilité
avis:
id: Avis
etablissement:
entreprise_siren: SIREN
entreprise_forme_juridique: Forme juridique