Possibilité d'afficher ou non une section pour un utilisateur.
This commit is contained in:
parent
fe6f6ebad3
commit
1696d0a159
4 changed files with 42 additions and 14 deletions
|
@ -23,6 +23,7 @@ function action_type_de_champs() {
|
|||
});
|
||||
|
||||
address_type_init();
|
||||
toggle_header_section_composents();
|
||||
}
|
||||
|
||||
function toggleErrorClass(node, boolean) {
|
||||
|
@ -45,3 +46,21 @@ function validateEmail(email) {
|
|||
function validateInput(input, regex) {
|
||||
return regex.test(input);
|
||||
}
|
||||
|
||||
function toggle_header_section_composents() {
|
||||
$("a.mask_section_button").on('click', function (e) {
|
||||
target = e.currentTarget;
|
||||
|
||||
header_section_id = target.id.split('mask_button_')[1];
|
||||
header_section_composents = $(".header_section_" + header_section_id);
|
||||
|
||||
header_section_composents.slideToggle(200, function(){
|
||||
if (header_section_composents.css('display') == 'none') {
|
||||
$(target).html('Afficher la section <i class="fa fa-chevron-down" />')
|
||||
}
|
||||
else {
|
||||
$(target).html('Masquer la section <i class="fa fa-chevron-up" />')
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
|
@ -1,26 +1,25 @@
|
|||
-actual_header_section = nil
|
||||
-@champs.each do |champ|
|
||||
.row
|
||||
.row{class: (actual_header_section.nil? || champ.type_champ == 'header_section' ? '' : "header_section_"+actual_header_section.to_s)}
|
||||
%div{class: "type_champ-#{champ.type_champ}"}
|
||||
-if champ.type_champ == 'checkbox'
|
||||
%h4{style:'margin-left:15px;'}
|
||||
= champ.libelle
|
||||
- if champ.mandatory?
|
||||
= '*'
|
||||
%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')}
|
||||
|
||||
- elsif champ.type_champ == 'header_section'
|
||||
- if champ.type_champ == 'header_section'
|
||||
=render partial: 'users/description/champs/header_section', locals: {champ: champ}
|
||||
-actual_header_section = champ.id
|
||||
|
||||
-else
|
||||
%h4
|
||||
= champ.libelle
|
||||
- if champ.mandatory?
|
||||
= '*'
|
||||
- unless champ.type_champ == 'checkbox'
|
||||
%h4
|
||||
= champ.libelle
|
||||
- if champ.mandatory?
|
||||
= '*'
|
||||
|
||||
-if champ.type_champ == 'textarea'
|
||||
=render partial: 'users/description/champs/textarea', locals: {champ: champ}
|
||||
|
||||
-elsif champ.type_champ == 'checkbox'
|
||||
= render partial: 'users/description/champs/checkbox', locals: {champ: champ}
|
||||
|
||||
-elsif champ.type_champ == 'civilite'
|
||||
=render partial: 'users/description/champs/civilite', locals: {champ: champ}
|
||||
|
||||
|
|
6
app/views/users/description/champs/_checkbox.html.haml
Normal file
6
app/views/users/description/champs/_checkbox.html.haml
Normal file
|
@ -0,0 +1,6 @@
|
|||
%h4{style:'margin-left:15px;'}
|
||||
= champ.libelle
|
||||
- if champ.mandatory?
|
||||
= '*'
|
||||
%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')}
|
|
@ -1,2 +1,6 @@
|
|||
%h3.text-primary.page-header
|
||||
=champ.libelle
|
||||
=champ.libelle
|
||||
%span.mask_section{style:'float: right'}
|
||||
%a.mask_section_button.btn.btn-xs.btn-default{id: "mask_button_"+champ.id.to_s}
|
||||
Masquer la section
|
||||
%i.fa.fa-chevron-up
|
Loading…
Reference in a new issue