Order champs by 'order_place' on description page

Champs dimension of textarea form
This commit is contained in:
Xavier J 2015-11-03 16:52:58 +01:00
parent 6fbe735793
commit 3a4beadbd1
3 changed files with 30 additions and 25 deletions

View file

@ -3,7 +3,7 @@
#description_page #liste_champs{
h4{
padding-top: 10px;
margin-top: 35px;
}
}
@ -17,11 +17,12 @@
}
.type_champs-textarea {
@extend .col-md-9;
@extend .col-lg-9;
@extend .col-md-8;
@extend .col-lg-8;
textarea.form-control {
width:100%;
height: 133px;
}
}

View file

@ -4,6 +4,7 @@ class Users::DescriptionController < UsersController
@dossier = @dossier.decorate
@procedure = @dossier.procedure
@champs = @dossier.champs.joins(', types_de_champs').where('champs.type_de_champs_id = types_de_champs.id').order('order_place')
rescue ActiveRecord::RecordNotFound
flash.alert = t('errors.messages.dossier_not_found')
@ -18,7 +19,7 @@ class Users::DescriptionController < UsersController
def create
@dossier = current_user_dossier
unless @dossier.update_attributes(create_params)
unless @dossier.update_attributes(create_params)
@dossier = @dossier.decorate
@procedure = @dossier.procedure
@ -31,9 +32,11 @@ class Users::DescriptionController < UsersController
cerfa.save
end
@dossier.champs.each do |champ|
champ.value = params[:champs]["'#{champ.id}'"]
champ.save
unless params[:champs].nil?
@dossier.champs.each do |champ|
champ.value = params[:champs]["'#{champ.id}'"]
champ.save
end
end
@dossier.pieces_justificatives.each do |piece_justificative|

View file

@ -13,28 +13,29 @@
.col-md-12
%h4 Description de votre projet *
= text_area_tag :description, @dossier.description, rows: '6', placeholder: 'Description du projet', class: 'form-control'
%br
#liste_champs.row
-@dossier.champs.each do |champ|
%div{class: "type_champs-#{champ.type_champs}"}
%h4
= champ.libelle
-unless @champs.nil?
-@champs.each do |champ|
%div{class: "type_champs-#{champ.type_champs}"}
%h4
= champ.libelle
-if champ.type_champs == 'textarea'
%textarea.form-control{name:"champs['#{champ.id}']",
placeholder: champ.libelle,
id: "champs_#{champ.id}"}
=champ.value
-else
%input.form-control{name:"champs[#{champ.id}]",
value: champ.value,
placeholder: champ.libelle,
id: "champs_#{champ.id}",
type:"#{champ.type_champs}",
'data-provide' => ('datepicker' if champ.type_champs == 'datetime'),
'data-date-format' => ('dd/mm/yyyy' if champ.type_champs == 'datetime')}
-if champ.type_champs == 'textarea'
%textarea.form-control{name:"champs['#{champ.id}']",
placeholder: champ.libelle,
id: "champs_#{champ.id}"}
=champ.value
-else
%input.form-control{name:"champs['#{champ.id}']",
value: champ.value,
placeholder: champ.libelle,
id: "champs_#{champ.id}",
type:"#{champ.type_champs}",
'data-provide' => ('datepicker' if champ.type_champs == 'datetime'),
'data-date-format' => ('dd/mm/yyyy' if champ.type_champs == 'datetime')}
%br
%h3 Documents administratifs
%br