From d2f91a64054f1923388c7f2d20de2d3a3b2940a6 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Thu, 1 Jun 2023 14:54:58 +0200 Subject: [PATCH 1/3] add list of PJ in procedure description --- app/models/procedure.rb | 8 ++++++++ .../shared/_procedure_description.html.haml | 19 +++++++++++++++---- config/locales/en.yml | 1 + config/locales/fr.yml | 1 + .../_procedure_description.html.haml_spec.rb | 19 +++++++++++++++++++ 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 99d90149e..aa56661f8 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -965,6 +965,14 @@ class Procedure < ApplicationRecord end end + def pieces_jointes_list + if publiee? + published_types_de_champ_public.filter(&:piece_justificative?) + else + draft_types_de_champ_public.filter(&:piece_justificative?) + end + end + private def validate_auto_archive_on_in_the_future diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index f68815546..77fe35198 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -28,7 +28,7 @@ %h2.fr-accordion__title %button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } = t('activerecord.attributes.procedure.description') - #accordion-114.fr-collapse.js_description + #accordion-114.fr-collapse = h render SimpleFormatComponent.new(procedure.description, allow_a: true) - if procedure.description_target_audience.present? @@ -36,15 +36,26 @@ %h2.fr-accordion__title %button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } = t('activerecord.attributes.procedure.description_target_audience') - #accordion-115.fr-collapse.js_description_target_audience + #accordion-115.fr-collapse = h render SimpleFormatComponent.new(procedure.description_target_audience, allow_a: true) + - if procedure.pieces_jointes_list.present? + %section.fr-accordion.pieces_jointes + %h2.fr-accordion__title + %button.fr-accordion__btn{ "aria-controls" => "accordion-116", "aria-expanded" => "false" } + = t('shared.procedure_description.pieces_jointes') + #accordion-116.fr-collapse + %ul + - procedure.pieces_jointes_list.each do |pj| + %li + = pj.libelle + - if procedure.persisted? && procedure.estimated_duration_visible? %section.fr-accordion %h2.fr-accordion__title - %button.fr-accordion__btn{ "aria-controls" => "accordion-116", "aria-expanded" => "false" } + %button.fr-accordion__btn{ "aria-controls" => "accordion-117", "aria-expanded" => "false" } = t('shared.procedure_description.estimated_fill_duration_title') - #accordion-116.fr-collapse.js_description_target_audience + #accordion-117.fr-collapse = t('shared.procedure_description.estimated_fill_duration_detail', estimated_minutes: estimated_fill_duration_minutes(procedure)) - if procedure.notice.attached? diff --git a/config/locales/en.yml b/config/locales/en.yml index e002d01d9..bfac2710b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -823,3 +823,4 @@ en: estimated_fill_duration: "Estimated fill time: %{estimated_minutes} mn" estimated_fill_duration_title: What is the procedure estimated fill time ? estimated_fill_duration_detail: "The fill time is etimated to %{estimated_minutes} min. This period may vary depending on the options you choose" + pieces_jointes : What are the required attachments ? diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 869158552..648cf3976 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -869,3 +869,4 @@ fr: estimated_fill_duration: "Temps de remplissage estimé : %{estimated_minutes} mn" estimated_fill_duration_title: Quelle est la durée de remplissage de la démarche ? estimated_fill_duration_detail: "La durée de remplissage est estimée à %{estimated_minutes} min. Ce délai peut varier selon les options que vous choisirez." + pieces_jointes : Quelles sont les pièces justificatives à fournir ? diff --git a/spec/views/shared/_procedure_description.html.haml_spec.rb b/spec/views/shared/_procedure_description.html.haml_spec.rb index 431de7fe3..bf8f9c582 100644 --- a/spec/views/shared/_procedure_description.html.haml_spec.rb +++ b/spec/views/shared/_procedure_description.html.haml_spec.rb @@ -10,6 +10,7 @@ describe 'shared/_procedure_description', type: :view do expect(rendered).to have_text(procedure.libelle) expect(rendered).to have_text(procedure.description) expect(rendered).to have_text('Temps de remplissage estimé') + expect(rendered).not_to have_text('Quelles sont les pièces justificatives à fournir') end context 'procedure with estimated duration not visible' do @@ -32,4 +33,22 @@ describe 'shared/_procedure_description', type: :view do expect(rendered).to have_text('Date limite') end end + + context 'when the procedure has pieces jointes' do + let(:procedure) { create(:procedure, :draft, :with_titre_identite, :with_piece_justificative, :with_siret) } + it 'shows the pieces jointes list for draft procedure' do + subject + expect(rendered).to have_text('Quelles sont les pièces justificatives à fournir') + expect(rendered).to have_text('Libelle du champ') + expect(rendered).to have_selector('.pieces_jointes ul li', count: 2) + end + + it 'shows the pieces jointes list for published procedure' do + procedure.publish! + subject + expect(rendered).to have_text('Quelles sont les pièces justificatives à fournir') + expect(rendered).to have_text('Libelle du champ') + expect(rendered).to have_selector('.pieces_jointes ul li', count: 2) + end + end end From 4b6d18608e3aa80beb74d1919aa26994812108b1 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Tue, 13 Jun 2023 10:49:16 +0200 Subject: [PATCH 2/3] split pj in two lists regarding to conditionnal --- app/models/procedure.rb | 16 ++++++++------ .../shared/_procedure_description.html.haml | 21 ++++++++++++++----- config/locales/en.yml | 2 ++ config/locales/fr.yml | 2 ++ 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index aa56661f8..042f976a2 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -965,12 +965,16 @@ class Procedure < ApplicationRecord end end - def pieces_jointes_list - if publiee? - published_types_de_champ_public.filter(&:piece_justificative?) - else - draft_types_de_champ_public.filter(&:piece_justificative?) - end + def pieces_jointes_list? + pieces_jointes_list_without_conditionnal.present? || pieces_jointes_list_with_conditionnal.present? + end + + def pieces_jointes_list_without_conditionnal + active_revision.types_de_champ_public.not_condition.filter(&:piece_justificative?) + end + + def pieces_jointes_list_with_conditionnal + active_revision.types_de_champ_public.where.not(condition: nil).filter(&:piece_justificative?) end private diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index 77fe35198..56a3907a9 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -39,16 +39,27 @@ #accordion-115.fr-collapse = h render SimpleFormatComponent.new(procedure.description_target_audience, allow_a: true) - - if procedure.pieces_jointes_list.present? + - if procedure.pieces_jointes_list? %section.fr-accordion.pieces_jointes %h2.fr-accordion__title %button.fr-accordion__btn{ "aria-controls" => "accordion-116", "aria-expanded" => "false" } = t('shared.procedure_description.pieces_jointes') #accordion-116.fr-collapse - %ul - - procedure.pieces_jointes_list.each do |pj| - %li - = pj.libelle + - if procedure.pieces_jointes_list_without_conditionnal.present? + %ul + - procedure.pieces_jointes_list_without_conditionnal.each do |pj| + %li + = pj.libelle + = t('utils.no_mandatory') unless pj.mandatory? + + - if procedure.pieces_jointes_list_with_conditionnal.present? + %h3.fr-text--sm.fr-mb-0.fr-mt-2w + = t('shared.procedure_description.pieces_jointes_conditionnal_list_title') + %ul + - procedure.pieces_jointes_list_with_conditionnal.each do |pj| + %li + = pj.libelle + = t('utils.no_mandatory') unless pj.mandatory? - if procedure.persisted? && procedure.estimated_duration_visible? %section.fr-accordion diff --git a/config/locales/en.yml b/config/locales/en.yml index bfac2710b..58d1b12aa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -51,6 +51,7 @@ en: pj: "Attachments" asterisk_html: Fields marked by an asterisk ( * ) are mandatory. mandatory_champs: All fields are mandatory. + no_mandatory: (optional) file_number: File number subject: Subject message: Message @@ -824,3 +825,4 @@ en: estimated_fill_duration_title: What is the procedure estimated fill time ? estimated_fill_duration_detail: "The fill time is etimated to %{estimated_minutes} min. This period may vary depending on the options you choose" pieces_jointes : What are the required attachments ? + pieces_jointes_conditionnal_list_title : Attachments list according to your situation diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 648cf3976..ca957e10a 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -42,6 +42,7 @@ fr: pj: "Pièces jointes" asterisk_html: Les champs suivis d’un astérisque ( * ) sont obligatoires. mandatory_champs: Tous les champs sont obligatoires. + no_mandatory: (facultatif) file_number: Numéro de dossier subject: Sujet message: Message @@ -870,3 +871,4 @@ fr: estimated_fill_duration_title: Quelle est la durée de remplissage de la démarche ? estimated_fill_duration_detail: "La durée de remplissage est estimée à %{estimated_minutes} min. Ce délai peut varier selon les options que vous choisirez." pieces_jointes : Quelles sont les pièces justificatives à fournir ? + pieces_jointes_conditionnal_list_title : Liste des pièces en fonction de votre situation From 30cf71b3607d19779c37c8fe6f080b8295bd0fb7 Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Thu, 15 Jun 2023 14:33:13 +0200 Subject: [PATCH 3/3] change 'unless' for 'if !' --- app/views/shared/_procedure_description.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index 56a3907a9..15696b47b 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -50,7 +50,7 @@ - procedure.pieces_jointes_list_without_conditionnal.each do |pj| %li = pj.libelle - = t('utils.no_mandatory') unless pj.mandatory? + = t('utils.no_mandatory') if !pj.mandatory? - if procedure.pieces_jointes_list_with_conditionnal.present? %h3.fr-text--sm.fr-mb-0.fr-mt-2w @@ -59,7 +59,7 @@ - procedure.pieces_jointes_list_with_conditionnal.each do |pj| %li = pj.libelle - = t('utils.no_mandatory') unless pj.mandatory? + = t('utils.no_mandatory') if !pj.mandatory? - if procedure.persisted? && procedure.estimated_duration_visible? %section.fr-accordion