Add header section on procédure champ

This commit is contained in:
Xavier J 2016-07-20 11:38:19 +02:00
parent 6796ec26e8
commit e7830deefa
8 changed files with 69 additions and 9 deletions

View file

@ -1,5 +1,10 @@
$(document).on('page:load', destroy_action); $(document).on('page:load', init_admin);
$(document).ready(destroy_action); $(document).ready(init_admin);
function init_admin(){
destroy_action();
on_change_type_de_champ_select();
}
function destroy_action(){ function destroy_action(){
$(".delete").on('click', function(){ $(".delete").on('click', function(){
@ -16,3 +21,18 @@ function destroy_action(){
setTimeout(destroy_action, 500); setTimeout(destroy_action, 500);
}); });
} }
function on_change_type_de_champ_select (){
$("select.form-control.type_champ").on('change', function(e){
parent = $(this).parent().parent()
if (this.value === 'header_section') {
parent.addClass('header_section')
}
else {
parent.removeClass('header_section')
}
})
}

View file

@ -0,0 +1,18 @@
.header_section{
background-color: rgb(245,245,245);
margin-top: 20px;
margin-bottom: 10px;
margin-left: 0;
margin-right: 0;
text-align:center;
padding-bottom: 8px;
.form-group.description {
display: none;
}
.form-group.mandatory {
display: none;
}
}

View file

@ -7,6 +7,10 @@
} }
} }
.page-header{
border-bottom: 1px solid #CCCCCC !important;
}
.input-error { .input-error {
color: darkred !important; color: darkred !important;
border-color: darkred !important border-color: darkred !important
@ -21,6 +25,13 @@
} }
} }
.type_champ-header_section {
@extend .col-md-12;
@extend .col-lg-12;
margin-bottom: -25px;
}
.type_champ-address { .type_champ-address {
@extend .col-md-6; @extend .col-md-6;
@extend .col-lg-6; @extend .col-lg-6;

View file

@ -10,7 +10,8 @@ class TypeDeChamp < ActiveRecord::Base
email: 'email', email: 'email',
phone: 'phone', phone: 'phone',
address: 'address', address: 'address',
yes_no: 'yes_no' yes_no: 'yes_no',
header_section: 'header_section'
} }
belongs_to :procedure belongs_to :procedure

View file

@ -1,15 +1,18 @@
= f.fields_for :types_de_champ, types_de_champ, remote: true do |ff| = f.fields_for :types_de_champ, types_de_champ, remote: true do |ff|
.form-inline .form-inline{class:"#{ff.object.object.type_champ == 'header_section' ? 'header_section' : ''}"}
.form-group .form-group.libelle
%h4 Libellé %h4 Libellé
= ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé' = ff.text_field :libelle, class: 'form-control libelle', placeholder: 'Libellé'
.form-group
.form-group.type
%h4 Type %h4 Type
= ff.select :type_champ, TypeDeChamp.type_champs, {}, {class: 'form-control type_champ'} = ff.select :type_champ, TypeDeChamp.type_champs, {}, {class: 'form-control type_champ'}
.form-group
.form-group.description
%h4 Description %h4 Description
= ff.text_area :description, class: 'form-control description', placeholder: 'Description' = ff.text_area :description, class: 'form-control description', placeholder: 'Description'
.form-group
.form-group.mandatory
%h4 Obligatoire ? %h4 Obligatoire ?
.center .center
= ff.check_box :mandatory, placeholder: 'Obligatoire ?' = ff.check_box :mandatory, placeholder: 'Obligatoire ?'

View file

@ -2,3 +2,4 @@
$("#flash_message").html("<div class=\"alert alert-success move_up\" style=\"display: block:\"> <%= message.html_safe %></div>").children().fadeOut(5000) $("#flash_message").html("<div class=\"alert alert-success move_up\" style=\"display: block:\"> <%= message.html_safe %></div>").children().fadeOut(5000)
<% end %> <% end %>
$('#liste_champ').html("<%= escape_javascript(render partial: 'form', locals: { procedure: @procedure, types_de_champ: @types_de_champ } ) %>"); $('#liste_champ').html("<%= escape_javascript(render partial: 'form', locals: { procedure: @procedure, types_de_champ: @types_de_champ } ) %>");
on_change_type_de_champ_select ();

View file

@ -8,6 +8,10 @@
= '*' = '*'
%input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''} %input{type: 'hidden', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", value: ''}
%input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')} %input{type: 'checkbox', style:'margin-left: 15px;', name:"champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on')}
- elsif champ.type_champ == 'header_section'
=render partial: 'users/description/champs/header_section', locals: {champ: champ}
-else -else
%h4 %h4
= champ.libelle = champ.libelle

View file

@ -0,0 +1,2 @@
%h3.text-primary.page-header
=champ.libelle