From 0cec8947d97a04a160f7aa4f82bb2344ba67b754 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 28 Jun 2023 09:55:57 +0200 Subject: [PATCH] chore(demande): no facultatif word on instructeur profile --- .../dossiers/champ_row_show_component.rb | 10 +++++++ .../champ_row_show_component.en.yml | 6 ++-- .../champ_row_show_component.fr.yml | 6 ++-- .../champ_row_show_component.html.haml | 2 +- .../shared/dossiers/_champs.html.haml_spec.rb | 28 +++++++++++++++++-- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/app/components/dossiers/champ_row_show_component.rb b/app/components/dossiers/champ_row_show_component.rb index 07c844cd9..ecaead685 100644 --- a/app/components/dossiers/champ_row_show_component.rb +++ b/app/components/dossiers/champ_row_show_component.rb @@ -2,6 +2,7 @@ class Dossiers::ChampRowShowComponent < ApplicationComponent include ChampHelper include DossierHelper include ApplicationHelper + def initialize(champs:, demande_seen_at:, profile:, repetition:) @repetition = repetition @champs = champs @@ -11,6 +12,7 @@ class Dossiers::ChampRowShowComponent < ApplicationComponent def updated_after_deposer?(champ) return false if champ.dossier.depose_at.blank? + champ.updated_at > champ.dossier.depose_at end @@ -18,4 +20,12 @@ class Dossiers::ChampRowShowComponent < ApplicationComponent # we are using the span delimiter that doesn't insert spaces when copying and pasting the number number_with_delimiter(num, delimiter: tag.span(class: 'numbers-delimiter')) end + + def blank_key(champ) + key = ".blank" + key += "_optional" if @profile == "usager" + key += "_attachment" if champ.type_de_champ.piece_justificative? + + key + end end 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 afb9ca162..3764ea7c1 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,4 +1,6 @@ --- en: - blank: "blank (optional)" - blank_attachment: "document not supplied (optional)" + blank: "empty" + blank_attachment: "document not supplied" + blank_optional: "empty (optional)" + blank_optional_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 7d4dee603..437f053bd 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,4 +1,6 @@ --- fr: - blank: "non saisi (facultatif)" - blank_attachment: "pièce justificative non saisie (facultative)" + blank: "non saisi" + blank_attachment: "pièce justificative non saisie" + blank_optional: "non saisi (facultatif)" + blank_optional_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 71e8c5d2a..6ca7301db 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 @@ -17,7 +17,7 @@ - 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(champ.type_de_champ.piece_justificative? ? '.blank_attachment' : '.blank') + %em= t(blank_key(champ)) - else .champ-content{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] } - case champ.type_champ diff --git a/spec/views/shared/dossiers/_champs.html.haml_spec.rb b/spec/views/shared/dossiers/_champs.html.haml_spec.rb index 1737cd6e9..ccb808886 100644 --- a/spec/views/shared/dossiers/_champs.html.haml_spec.rb +++ b/spec/views/shared/dossiers/_champs.html.haml_spec.rb @@ -1,14 +1,18 @@ describe 'shared/dossiers/champs', type: :view do let(:instructeur) { create(:instructeur) } let(:demande_seen_at) { nil } + let(:profile) { "instructeur" } before do view.extend DossierHelper view.extend DossierLinkHelper - allow(view).to receive(:current_instructeur).and_return(instructeur) + + if profile == "instructeur" + allow(view).to receive(:current_instructeur).and_return(instructeur) + end end - subject { render 'shared/dossiers/champs', champs: champs, dossier: dossier, demande_seen_at: demande_seen_at, profile: nil } + subject { render 'shared/dossiers/champs', champs:, dossier:, demande_seen_at:, profile: } context "there are some champs" do let(:dossier) { create(:dossier) } @@ -108,7 +112,25 @@ describe 'shared/dossiers/champs', type: :view do let(:champ) { create(:champ_dossier_link, dossier: dossier, value: nil) } let(:champs) { [champ] } - it { is_expected.to include("non saisi (facultatif)") } + it { is_expected.to include("non saisi") } + + context 'when profile is usager' do + let(:profile) { "usager" } + it { is_expected.to include("non saisi (facultatif)") } + end + end + + context "with a piece justificative without value" do + let(:dossier) { create(:dossier) } + let(:champ) { create(:champ_without_piece_justificative, dossier:) } + let(:champs) { [champ] } + + it { is_expected.to include("pièce justificative non saisie") } + + context 'when profile is usager' do + let(:profile) { "usager" } + it { is_expected.to include("pièce justificative non saisie (facultative)") } + end end context "with seen_at" do