Merge pull request #8936 from demarches-simplifiees/add-yes-no-column-for-instructeurs

[instructeur] ajout du nb de réponses oui/non aux avis dans le tableau d'une procedure
This commit is contained in:
Lisa Durand 2023-04-26 09:05:58 +00:00 committed by GitHub
commit e393132fd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 22 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 || 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_with_count.#{k}", count: v) }&.join(' / ')] }
# rubocop:enable Style/HashTransformValues
end
end

View file

@ -21,6 +21,9 @@ en:
question_answer:
true: 'yes'
false: 'no'
question_answer_with_count:
true: "yes : %{count}"
false: "no : %{count}"
confirmation:
revoke: "Would you like to revoke the opinion request to %{email} ?"
remind: "Would you like to remind %{email} ?"

View file

@ -21,6 +21,9 @@ fr:
question_answer:
true: oui
false: non
question_answer_with_count:
true: "oui : %{count}"
false: "non : %{count}"
confirmation:
revoke: "Souhaitez-vous révoquer la demande davis à %{email} ?"
remind: "Souhaitez-vous relancer %{email} ?"

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

View file

@ -73,6 +73,7 @@ describe ProcedurePresentation do
{ "label" => 'Demandeur', "table" => 'user', "column" => 'email', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'Email instructeur', "table" => 'followers_instructeurs', "column" => 'email', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'Groupe instructeur', "table" => 'groupe_instructeur', "column" => 'id', 'classname' => '', 'virtual' => false, 'type' => :enum, "scope" => '' },
{ "label" => 'Avis', "table" => 'avis', "column" => 'id', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'SIREN', "table" => 'etablissement', "column" => 'entreprise_siren', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'Forme juridique', "table" => 'etablissement', "column" => 'entreprise_forme_juridique', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },
{ "label" => 'Nom commercial', "table" => 'etablissement', "column" => 'entreprise_nom_commercial', 'classname' => '', 'virtual' => false, 'type' => :text, "scope" => '' },