chore(demande): no facultatif word on instructeur profile

This commit is contained in:
Colin Darie 2023-06-28 09:55:57 +02:00
parent 1bdc6c02c6
commit 0cec8947d9
5 changed files with 44 additions and 8 deletions

View file

@ -2,6 +2,7 @@ class Dossiers::ChampRowShowComponent < ApplicationComponent
include ChampHelper include ChampHelper
include DossierHelper include DossierHelper
include ApplicationHelper include ApplicationHelper
def initialize(champs:, demande_seen_at:, profile:, repetition:) def initialize(champs:, demande_seen_at:, profile:, repetition:)
@repetition = repetition @repetition = repetition
@champs = champs @champs = champs
@ -11,6 +12,7 @@ class Dossiers::ChampRowShowComponent < ApplicationComponent
def updated_after_deposer?(champ) def updated_after_deposer?(champ)
return false if champ.dossier.depose_at.blank? return false if champ.dossier.depose_at.blank?
champ.updated_at > champ.dossier.depose_at champ.updated_at > champ.dossier.depose_at
end 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 # 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')) number_with_delimiter(num, delimiter: tag.span(class: 'numbers-delimiter'))
end end
def blank_key(champ)
key = ".blank"
key += "_optional" if @profile == "usager"
key += "_attachment" if champ.type_de_champ.piece_justificative?
key
end
end end

View file

@ -1,4 +1,6 @@
--- ---
en: en:
blank: "blank (optional)" blank: "empty"
blank_attachment: "document not supplied (optional)" blank_attachment: "document not supplied"
blank_optional: "empty (optional)"
blank_optional_attachment: "document not supplied (optional)"

View file

@ -1,4 +1,6 @@
--- ---
fr: fr:
blank: "non saisi (facultatif)" blank: "non saisi"
blank_attachment: "pièce justificative non saisie (facultative)" blank_attachment: "pièce justificative non saisie"
blank_optional: "non saisi (facultatif)"
blank_optional_attachment: "pièce justificative non saisie (facultative)"

View file

@ -17,7 +17,7 @@
- if champ.blank? - if champ.blank?
.champ-content.fr-text-mention--grey{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] } .champ-content.fr-text-mention--grey{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] }
%p %p
%em= t(champ.type_de_champ.piece_justificative? ? '.blank_attachment' : '.blank') %em= t(blank_key(champ))
- else - else
.champ-content{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] } .champ-content{ class: [highlight_if_unseen_class(@demande_seen_at, champ.updated_at), champ.type_champ] }
- case champ.type_champ - case champ.type_champ

View file

@ -1,14 +1,18 @@
describe 'shared/dossiers/champs', type: :view do describe 'shared/dossiers/champs', type: :view do
let(:instructeur) { create(:instructeur) } let(:instructeur) { create(:instructeur) }
let(:demande_seen_at) { nil } let(:demande_seen_at) { nil }
let(:profile) { "instructeur" }
before do before do
view.extend DossierHelper view.extend DossierHelper
view.extend DossierLinkHelper view.extend DossierLinkHelper
if profile == "instructeur"
allow(view).to receive(:current_instructeur).and_return(instructeur) allow(view).to receive(:current_instructeur).and_return(instructeur)
end 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 context "there are some champs" do
let(:dossier) { create(:dossier) } let(:dossier) { create(:dossier) }
@ -108,8 +112,26 @@ describe 'shared/dossiers/champs', type: :view do
let(:champ) { create(:champ_dossier_link, dossier: dossier, value: nil) } let(:champ) { create(:champ_dossier_link, dossier: dossier, value: nil) }
let(:champs) { [champ] } let(:champs) { [champ] }
it { is_expected.to include("non saisi") }
context 'when profile is usager' do
let(:profile) { "usager" }
it { is_expected.to include("non saisi (facultatif)") } it { is_expected.to include("non saisi (facultatif)") }
end 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 context "with seen_at" do
let(:dossier) { create(:dossier) } let(:dossier) { create(:dossier) }