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

View file

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

View file

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