refactor(champs): use ViewableChamp::SectionComponent

This commit is contained in:
Paul Chavard 2024-03-12 14:28:19 +01:00
parent 83cd291593
commit fd2e253ebc
4 changed files with 4 additions and 5 deletions

View file

@ -15,13 +15,13 @@
- types_de_champ_public = @dossier.revision.types_de_champ_public
- if types_de_champ_public.any? || @dossier.procedure.routing_enabled?
= render partial: "shared/dossiers/champs", locals: { types_de_champ: types_de_champ_public, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' }
= render ViewableChamp::SectionComponent.new(types_de_champ: types_de_champ_public, champs_by_stable_id_with_row: @dossier.champs_by_stable_id_with_row, demande_seen_at: nil, profile: 'instructeur')
%h2 Annotations privées
- types_de_champ_private = @dossier.revision.types_de_champ_private
- if types_de_champ_private.any?
= render partial: "shared/dossiers/champs", locals: { types_de_champ: types_de_champ_private, dossier: @dossier, demande_seen_at: nil, profile: 'instructeur' }
= render ViewableChamp::SectionComponent.new(types_de_champ: types_de_champ_private, champs_by_stable_id_with_row: @dossier.champs_by_stable_id_with_row, demande_seen_at: nil, profile: 'instructeur')
- else
Aucune annotation privée

View file

@ -1 +0,0 @@
= render ViewableChamp::SectionComponent.new(types_de_champ:, champs_by_stable_id_with_row: dossier.champs_by_stable_id_with_row, demande_seen_at:, profile:)

View file

@ -53,4 +53,4 @@
- types_de_champ = dossier.revision.types_de_champ_public
- if types_de_champ.any? || dossier.procedure.routing_enabled?
= render partial: "shared/dossiers/champs", locals: { types_de_champ:, dossier:, demande_seen_at:, profile: }
= render ViewableChamp::SectionComponent.new(types_de_champ:, champs_by_stable_id_with_row: dossier.champs_by_stable_id_with_row, demande_seen_at:, profile:)

View file

@ -15,7 +15,7 @@ describe 'shared/dossiers/champs', type: :view do
end
end
subject { render 'shared/dossiers/champs', types_de_champ:, dossier:, demande_seen_at:, profile: }
subject { render ViewableChamp::SectionComponent.new(types_de_champ:, dossier:, demande_seen_at:, profile:) }
context "there are some champs" do
let(:types_de_champ_public) { [{ type: :checkbox }, { type: :header_section }, { type: :explication }, { type: :dossier_link }, { type: :textarea }, { type: :rna }] }