From 9338a733620f94c7d7097fe8bfbb6263c345452b Mon Sep 17 00:00:00 2001 From: Lisa Durand Date: Thu, 22 Jun 2023 09:50:38 +0200 Subject: [PATCH] add possibility to override generated pj list by admin --- .../administrateurs/procedures_controller.rb | 1 + app/models/procedure.rb | 1 + .../administrateurs/procedures/_informations.html.haml | 2 ++ app/views/shared/_procedure_description.html.haml | 10 +++++++++- config/locales/models/procedure/en.yml | 3 +++ config/locales/models/procedure/fr.yml | 3 +++ ...161733_add_pj_field_for_description_to_procedure.rb | 5 +++++ .../shared/_procedure_description.html.haml_spec.rb | 7 +++++++ 8 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230621161733_add_pj_field_for_description_to_procedure.rb diff --git a/app/controllers/administrateurs/procedures_controller.rb b/app/controllers/administrateurs/procedures_controller.rb index 9a74753d8..d0a2ac7f4 100644 --- a/app/controllers/administrateurs/procedures_controller.rb +++ b/app/controllers/administrateurs/procedures_controller.rb @@ -454,6 +454,7 @@ module Administrateurs :libelle, :description, :description_target_audience, + :description_pj, :organisation, :direction, :lien_site_web, diff --git a/app/models/procedure.rb b/app/models/procedure.rb index d2c1fae70..bb007e4c5 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -16,6 +16,7 @@ # closed_at :datetime # declarative_with_state :string # description :string +# description_pj :string # description_target_audience :string # dossiers_count_computed_at :datetime # duree_conservation_dossiers_dans_ds :integer diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index 88daf5c21..15330dfca 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -10,6 +10,8 @@ = render Dsfr::InputComponent.new(form: f, attribute: :description_target_audience, input_type: :text_area, opts: {}, required: false) += render Dsfr::InputComponent.new(form: f, attribute: :description_pj, input_type: :text_area, opts: {placeholder: t('activerecord.attributes.procedure.description_pj_placeholder')}, required: false) + = f.label :logo, 'Ajouter un logo de la démarche (facultatif)', class: 'fr-label' = render Attachment::EditComponent.new(attached_file: @procedure.logo, view_as: :link) diff --git a/app/views/shared/_procedure_description.html.haml b/app/views/shared/_procedure_description.html.haml index 15696b47b..cc8fb366d 100644 --- a/app/views/shared/_procedure_description.html.haml +++ b/app/views/shared/_procedure_description.html.haml @@ -39,7 +39,15 @@ #accordion-115.fr-collapse = h render SimpleFormatComponent.new(procedure.description_target_audience, allow_a: true) - - if procedure.pieces_jointes_list? + - if procedure.description_pj.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 + = h render SimpleFormatComponent.new(procedure.description_pj, allow_a: true) + + - elsif procedure.pieces_jointes_list? %section.fr-accordion.pieces_jointes %h2.fr-accordion__title %button.fr-accordion__btn{ "aria-controls" => "accordion-116", "aria-expanded" => "false" } diff --git a/config/locales/models/procedure/en.yml b/config/locales/models/procedure/en.yml index 037aedc4f..fabfef04c 100644 --- a/config/locales/models/procedure/en.yml +++ b/config/locales/models/procedure/en.yml @@ -9,12 +9,15 @@ en: hints: description: Describe in a few lines the context, the aim etc. description_target_audience: Describe in a few lines the final recipients of the process, the eligibility criteria if there are any, the prerequisites, etc. + description_pj: Describe the required attachments list if there is any lien_site_web: "Exemple: 'https://exemple.gouv.fr/ma_demarche'" cadre_juridique: "Exemple: 'https://www.legifrance.gouv.fr/'" path: Public link organisation: Service description: What is the purpose of this procedure? description_target_audience: Who is the procedure intended for? + description_pj: Required attachments list + description_pj_placeholder: If you leave this field blank and your form contains attachments, an automatically generated list will be displayed on the home page of your procedure. lien_site_web: Where will users find the link to the procedure? cadre_juridique: Link to the legal text lien_dpo: Link or email to contact the data protection officer (DPO) diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index a6578ecee..6f6b49cd9 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -9,6 +9,7 @@ fr: hints: description: Décrivez en quelques lignes le contexte, la finalité, etc. description_target_audience: Décrivez en quelques lignes les destinataires finaux de la démarche, les critères d’éligibilité s’il y en a, les pré-requis, etc. + description_pj: Décrivez la liste des pièces jointes à fournir s’il y en a lien_site_web: "Exemple: 'https://exemple.gouv.fr/ma_demarche'" cadre_juridique: "Exemple: 'https://www.legifrance.gouv.fr/'" path: Lien public @@ -19,6 +20,8 @@ fr: libelle: Titre de la démarche description: Quel est l’objet de la démarche ? description_target_audience: À qui s’adresse la démarche ? + description_pj: Liste des pièces jointes demandées + description_pj_placeholder: Si vous ne renseignez pas ce champ et que votre formulaire contient des pièces jointes, une liste générée automatiquement s'affichera dans la page d'accueil de votre démarche. lien_site_web: Où les usagers trouveront-ils le lien vers la démarche ? cadre_juridique: Lien vers le texte lien_dpo: Lien ou email pour contacter le Délégué à la Protection des Données (DPO) diff --git a/db/migrate/20230621161733_add_pj_field_for_description_to_procedure.rb b/db/migrate/20230621161733_add_pj_field_for_description_to_procedure.rb new file mode 100644 index 000000000..9f82bad33 --- /dev/null +++ b/db/migrate/20230621161733_add_pj_field_for_description_to_procedure.rb @@ -0,0 +1,5 @@ +class AddPjFieldForDescriptionToProcedure < ActiveRecord::Migration[7.0] + def change + add_column :procedures, :description_pj, :string + end +end diff --git a/spec/views/shared/_procedure_description.html.haml_spec.rb b/spec/views/shared/_procedure_description.html.haml_spec.rb index bf8f9c582..4973c8d58 100644 --- a/spec/views/shared/_procedure_description.html.haml_spec.rb +++ b/spec/views/shared/_procedure_description.html.haml_spec.rb @@ -50,5 +50,12 @@ describe 'shared/_procedure_description', type: :view do expect(rendered).to have_text('Libelle du champ') expect(rendered).to have_selector('.pieces_jointes ul li', count: 2) end + + it 'shows the manual description pieces jointes list if admin filled one' do + procedure.update!(description_pj: 'une description des pj manuelle') + subject + expect(rendered).to have_text('Quelles sont les pièces justificatives à fournir') + expect(rendered).to have_text('une description des pj manuelle') + end end end