Add header section in form table

This commit is contained in:
Mathieu Magnin 2017-07-11 16:50:29 +02:00
parent 7bb75c3f56
commit 2b0c0567b8
9 changed files with 94 additions and 10 deletions

View file

@ -1,3 +1,4 @@
@import "colors";
@import "constants"; @import "constants";
@import "mixins"; @import "mixins";
@ -13,6 +14,12 @@
th { th {
text-align: left; text-align: left;
&.header-section {
color: $blue;
font-weight: bold;
font-size: 20px;
}
} }
td { td {

View file

@ -0,0 +1,12 @@
%table.table
%tbody
- champs.each do |c|
%tr
- if c.type_champ == "header_section"
%th.header-section{ colspan: 2 }
= c.libelle
- else
%th
= "#{c.libelle} :"
%td
= c.value

View file

@ -7,17 +7,12 @@
- if @dossier.individual.present? - if @dossier.individual.present?
= render partial: "identite_individual", locals: { individual: @dossier.individual } = render partial: "identite_individual", locals: { individual: @dossier.individual }
.backoffice-title Formulaire
.card.featured .card.featured
.card-title Construction du dossier - champs = @dossier.ordered_champs.decorate
- if @dossier.champs.present? && @dossier.champs.any? - if champs.any?
%table.table = render partial: "champs", locals: { champs: champs }
%tbody
- @dossier.champs.decorate.each do |c|
%tr
%th
= "#{c.libelle} :"
%td
= c.value
- if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? - if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any?
.card.featured .card.featured

View file

@ -78,6 +78,8 @@
%tr %tr
%th Header 2 %th Header 2
%td Table Data 2 %td Table Data 2
%tr
%th.header-section{ colspan: 2 } Header section
%tr %tr
%th Header 3 %th Header 3
%td Table Data 3 %td Table Data 3

View file

@ -1,5 +1,13 @@
FactoryGirl.define do FactoryGirl.define do
factory :champ do factory :champ do
type_de_champ { FactoryGirl.create(:type_de_champ_public) } type_de_champ { FactoryGirl.create(:type_de_champ_public) }
trait :checkbox do
type_de_champ { FactoryGirl.create(:type_de_champ_public, :checkbox) }
end
trait :header_section do
type_de_champ { FactoryGirl.create(:type_de_champ_public, :header_section) }
end
end end
end end

View file

@ -10,5 +10,11 @@ FactoryGirl.define do
siret_siege_social '44011762001530' siret_siege_social '44011762001530'
code_effectif_entreprise '51' code_effectif_entreprise '51'
date_creation Time.at(1453976189).to_datetime date_creation Time.at(1453976189).to_datetime
trait :is_association do
after(:create) do |entreprise, _evaluator|
create(:rna_information, entreprise: entreprise)
end
end
end end
end end

View file

@ -10,6 +10,10 @@ FactoryGirl.define do
type_champ 'checkbox' type_champ 'checkbox'
end end
trait :header_section do
type_champ 'header_section'
end
trait :type_dossier_link do trait :type_dossier_link do
libelle 'Référence autre dossier' libelle 'Référence autre dossier'
type_champ 'dossier_link' type_champ 'dossier_link'

View file

@ -0,0 +1,15 @@
describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
before { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs }
context "there is some champs" do
let(:champ1) { create(:champ, :checkbox, value: "true") }
let(:champ2) { create(:champ, :header_section, value: "Section") }
let(:champs) { [champ1, champ2] }
it { expect(rendered).to include(champ1.libelle) }
it { expect(rendered).to include(champ1.value) }
it { expect(rendered).to have_css(".header-section") }
it { expect(rendered).to include(champ2.libelle) }
end
end

View file

@ -0,0 +1,35 @@
describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do
let(:individual) { nil }
let(:entreprise) { nil }
let(:dossier) { create(:dossier, :replied, entreprise: entreprise, individual: individual) }
before do
assign(:dossier, dossier)
render
end
context "when dossier was created by an entreprise" do
let(:entreprise) { create(:entreprise) }
it { expect(rendered).to include(entreprise.decorate.raison_sociale_or_name) }
it { expect(rendered).to include(entreprise.decorate.siret_siege_social) }
it { expect(rendered).to include(entreprise.decorate.forme_juridique) }
context "and entreprise is an association" do
let(:entreprise) { create(:entreprise, :is_association) }
it { expect(rendered).to include(entreprise.rna_information.association_id) }
it { expect(rendered).to include(entreprise.rna_information.titre) }
it { expect(rendered).to include(entreprise.rna_information.objet) }
end
end
context "when dossier was created by an individual" do
let(:individual) { create(:individual) }
it { expect(rendered).to include(individual.gender) }
it { expect(rendered).to include(individual.nom) }
it { expect(rendered).to include(individual.prenom) }
it { expect(rendered).to include(individual.birthdate) }
end
end