From 1bdc6c02c6de950c123bf02a590ae43dcaee6965 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 27 Jun 2023 17:38:37 +0200 Subject: [PATCH] style(demande): homogeneize "blank" champs and not attached files champs --- .../champ_row_show_component.en.yml | 1 + .../champ_row_show_component.fr.yml | 1 + .../champ_row_show_component.html.haml | 4 ++-- app/models/champs/piece_justificative_champ.rb | 4 ++++ app/models/champs/titre_identite_champ.rb | 4 ++++ .../champs/piece_justificative/_show.html.haml | 12 ++++-------- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/components/dossiers/champ_row_show_component/champ_row_show_component.en.yml b/app/components/dossiers/champ_row_show_component/champ_row_show_component.en.yml index 067154666..afb9ca162 100644 --- a/app/components/dossiers/champ_row_show_component/champ_row_show_component.en.yml +++ b/app/components/dossiers/champ_row_show_component/champ_row_show_component.en.yml @@ -1,3 +1,4 @@ --- en: blank: "blank (optional)" + blank_attachment: "document not supplied (optional)" diff --git a/app/components/dossiers/champ_row_show_component/champ_row_show_component.fr.yml b/app/components/dossiers/champ_row_show_component/champ_row_show_component.fr.yml index a4af6d922..7d4dee603 100644 --- a/app/components/dossiers/champ_row_show_component/champ_row_show_component.fr.yml +++ b/app/components/dossiers/champ_row_show_component/champ_row_show_component.fr.yml @@ -1,3 +1,4 @@ --- fr: blank: "non saisi (facultatif)" + blank_attachment: "pièce justificative non saisie (facultative)" diff --git a/app/components/dossiers/champ_row_show_component/champ_row_show_component.html.haml b/app/components/dossiers/champ_row_show_component/champ_row_show_component.html.haml index 5c545958c..71e8c5d2a 100644 --- a/app/components/dossiers/champ_row_show_component/champ_row_show_component.html.haml +++ b/app/components/dossiers/champ_row_show_component/champ_row_show_component.html.haml @@ -14,10 +14,10 @@ %span{ class: highlight_if_unseen_class(@demande_seen_at, champ.updated_at) } = t(:updated_at, scope: [:views, :shared, :dossiers, :form], datetime: try_format_datetime(champ.updated_at)) - - if champ.blank? && ![TypeDeChamp.type_champs.fetch(:piece_justificative), TypeDeChamp.type_champs.fetch(:titre_identite)].include?(champ.type_champ) + - if champ.blank? .champ-content.fr-text-mention--grey{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] } %p - %em= t('.blank') + %em= t(champ.type_de_champ.piece_justificative? ? '.blank_attachment' : '.blank') - else .champ-content{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] } - case champ.type_champ diff --git a/app/models/champs/piece_justificative_champ.rb b/app/models/champs/piece_justificative_champ.rb index f7e7a878b..e95af2bf5 100644 --- a/app/models/champs/piece_justificative_champ.rb +++ b/app/models/champs/piece_justificative_champ.rb @@ -43,6 +43,10 @@ class Champs::PieceJustificativeChamp < Champ mandatory? && !piece_justificative_file.attached? end + def blank? + piece_justificative_file.blank? + end + def for_export piece_justificative_file.map { _1.filename.to_s }.join(', ') end diff --git a/app/models/champs/titre_identite_champ.rb b/app/models/champs/titre_identite_champ.rb index d8fcad2d4..c9c925d97 100644 --- a/app/models/champs/titre_identite_champ.rb +++ b/app/models/champs/titre_identite_champ.rb @@ -37,6 +37,10 @@ class Champs::TitreIdentiteChamp < Champ mandatory? && !piece_justificative_file.attached? end + def blank? + piece_justificative_file.blank? + end + def for_export piece_justificative_file.attached? ? "présent" : "absent" end diff --git a/app/views/shared/champs/piece_justificative/_show.html.haml b/app/views/shared/champs/piece_justificative/_show.html.haml index 2b2eac563..dd81dde84 100644 --- a/app/views/shared/champs/piece_justificative/_show.html.haml +++ b/app/views/shared/champs/piece_justificative/_show.html.haml @@ -1,8 +1,4 @@ -- pj = champ.piece_justificative_file -- if pj.attached? - .fr-downloads-group - %ul - - pj.attachments.each do |attachment| - %li= render Attachment::ShowComponent.new(attachment:, new_tab: true) -- else - Pièce justificative non fournie +.fr-downloads-group + %ul + - champ.piece_justificative_file.attachments.each do |attachment| + %li= render Attachment::ShowComponent.new(attachment:, new_tab: true)