amelioration(instructeurs/dossiers/show): ETQ instructeur, je vois les champs saisi, les champs qui ont ete vidé apres le depot du dossier, je ne vois pas les champs facultatif jamais saisis
This commit is contained in:
parent
8abd632e1f
commit
dfb525892a
3 changed files with 30 additions and 3 deletions
|
@ -28,4 +28,31 @@ class Dossiers::ChampRowShowComponent < ApplicationComponent
|
|||
|
||||
key
|
||||
end
|
||||
|
||||
def each_champ(&block)
|
||||
@champs.filter { show_champ?(_1) }.each(&block)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# champ.blank? is overloaded, disable the cop
|
||||
# rubocop:disable Rails/Present
|
||||
def show_champ?(champ)
|
||||
if view_usager?
|
||||
true
|
||||
elsif champ.blank? && updated_after_deposer?(champ)
|
||||
true
|
||||
else
|
||||
!champ.blank?
|
||||
end
|
||||
end
|
||||
# rubocop:enable Rails/Present
|
||||
|
||||
def view_usager?
|
||||
@profile == 'usager'
|
||||
end
|
||||
|
||||
def view_instructeur?
|
||||
@profile == 'instructeur'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- @champs.each do |champ|
|
||||
- each_champ do |champ|
|
||||
.fr-px-4v.fr-my-2v
|
||||
- if champ.repetition?
|
||||
%p.champ-label= "#{champ.libelle} :"
|
||||
|
|
|
@ -112,7 +112,7 @@ 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") }
|
||||
it { is_expected.not_to include("non saisi") }
|
||||
|
||||
context 'when profile is usager' do
|
||||
let(:profile) { "usager" }
|
||||
|
@ -125,7 +125,7 @@ describe 'shared/dossiers/champs', type: :view do
|
|||
let(:champ) { create(:champ_without_piece_justificative, dossier:) }
|
||||
let(:champs) { [champ] }
|
||||
|
||||
it { is_expected.to include("pièce justificative non saisie") }
|
||||
it { is_expected.not_to include("pièce justificative non saisie") }
|
||||
|
||||
context 'when profile is usager' do
|
||||
let(:profile) { "usager" }
|
||||
|
|
Loading…
Add table
Reference in a new issue