split pj in two lists regarding to conditionnal

This commit is contained in:
Lisa Durand 2023-06-13 10:49:16 +02:00
parent d2f91a6405
commit 4b6d18608e
4 changed files with 30 additions and 11 deletions

View file

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

View file

@ -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
- if procedure.pieces_jointes_list_without_conditionnal.present?
%ul
- procedure.pieces_jointes_list.each do |pj|
- 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

View file

@ -51,6 +51,7 @@ en:
pj: "Attachments"
asterisk_html: Fields marked by an asterisk ( <span class = mandatory>*</span> ) 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

View file

@ -42,6 +42,7 @@ fr:
pj: "Pièces jointes"
asterisk_html: Les champs suivis dun 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