Merge pull request #4754 from betagouv/show_repetable_champ_in_manager_procedure

Manager : permet de visualiser le contenu d'un type de champ répétable
This commit is contained in:
Pierre de La Morinerie 2020-02-11 15:16:54 +01:00 committed by GitHub
commit fbdbf997e4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 23 deletions

View file

@ -4,31 +4,15 @@
%tr
%td.cell-label Libelle
%td.cell-label Type de champ
%td.cell-label Rempli
%td.cell-label Modifier le modèle
%tbody
- field.data.order(:order_place).each do |f|
%tr
%td.cell-data
= f.libelle
- if f.mandatory?
%span.mandatory{ style: 'color: #A10005;' } *
%td.cell-data
= I18n.t("activerecord.attributes.type_de_champ.type_champs.#{f.type_champ}")
- field.data.order(:order_place).each do |type_de_champ|
= render partial: 'fields/types_de_champ_collection_field/type_champ_line',
locals: { type_de_champ: type_de_champ }
%td.cell-data
- if f.blank?
vide
- else
rempli
%td.cell-data
- if f.type_champ == 'piece_justificative'
= form_for f,
url: change_piece_justificative_template_manager_procedure_path,
method: :post do |form|
= form.hidden_field :id
= form.file_field :piece_justificative_template
= form.submit 'modifier'
- if type_de_champ.type_champ == 'repetition'
- type_de_champ.types_de_champ.each do |sub_champ|
= render partial: 'fields/types_de_champ_collection_field/type_champ_line',
locals: { type_de_champ: sub_champ }
- else
Aucun

View file

@ -0,0 +1,16 @@
%tr
%td.cell-data
= type_de_champ.libelle
- if type_de_champ.mandatory?
%span.mandatory{ style: 'color: #A10005;' } *
%td.cell-data
= I18n.t("activerecord.attributes.type_de_champ.type_champs.#{type_de_champ.type_champ}")
%td.cell-data
- if type_de_champ.type_champ == 'piece_justificative'
= form_for type_de_champ,
url: change_piece_justificative_template_manager_procedure_path,
method: :post do |form|
= form.hidden_field :id
= form.file_field :piece_justificative_template
= form.submit 'modifier'

View file

@ -11,4 +11,18 @@ describe Manager::ProceduresController, type: :controller do
it { expect(procedure.whitelisted_at).not_to be_nil }
end
describe '#show' do
render_views
let(:administration) { create(:administration) }
let!(:procedure) { create(:procedure, :with_repetition) }
before do
sign_in(administration)
get :show, params: { id: procedure.id }
end
it { expect(response.body).to include('sub type de champ') }
end
end

View file

@ -153,6 +153,15 @@ FactoryBot.define do
end
end
trait :with_repetition do
after(:build) do |procedure, _evaluator|
type_de_champ = create(:type_de_champ_repetition)
procedure.types_de_champ << type_de_champ
type_de_champ.types_de_champ << create(:type_de_champ, libelle: 'sub type de champ')
end
end
trait :published do
after(:build) do |procedure, _evaluator|
procedure.path = generate(:published_path)