[#1421] Add linked dropown fields

This commit is contained in:
Frederic Merizen 2018-06-14 12:53:27 +02:00
parent 859d8896f8
commit 15e8d8af05
7 changed files with 12 additions and 1 deletions

View file

@ -38,6 +38,7 @@ function on_change_type_de_champ_select (){
break;
case 'drop_down_list':
case 'multiple_drop_down_list':
case 'linked_drop_down_list':
parent.children(".drop-down-list").addClass('show-inline');
break;
case 'piece_justificative':

View file

@ -0,0 +1,2 @@
class Champs::LinkedDropDownListChamp < Champ
end

View file

@ -13,6 +13,7 @@ class TypeDeChamp < ApplicationRecord
yes_no: 'yes_no',
drop_down_list: 'drop_down_list',
multiple_drop_down_list: 'multiple_drop_down_list',
linked_drop_down_list: 'linked_drop_down_list',
pays: 'pays',
regions: 'regions',
departements: 'departements',

View file

@ -0,0 +1,2 @@
class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypeDeChamp
end

View file

@ -14,7 +14,7 @@
%h4 Description
= ff.text_area :description, class: 'form-control description', placeholder: 'Description', rows: 3
.form-group.drop-down-list{ class: (%w(drop_down_list multiple_drop_down_list).include?(type_champ) ? 'show-inline' : nil), style: 'margin-right: 5px;' }
.form-group.drop-down-list{ class: (%w(drop_down_list multiple_drop_down_list linked_drop_down_list).include?(type_champ) ? 'show-inline' : nil), style: 'margin-right: 5px;' }
%h4 Liste déroulante
= ff.fields_for :drop_down_list_attributes, ff.object.object.drop_down_list do |fff|
~ fff.text_area :value, class: 'form-control drop_down_list', placeholder: "Ecrire une valeur par ligne et --valeur-- pour un séparateur.", rows: 3, cols: 30

View file

@ -18,6 +18,7 @@ fr:
yes_no: 'Oui/Non'
drop_down_list: 'Menu déroulant'
multiple_drop_down_list: 'Menu déroulant à choix multiples'
linked_drop_down_list: 'Deux menus déroulants liés'
pays: 'Pays'
regions: 'Régions'
departements: 'Départements'

View file

@ -50,6 +50,10 @@ FactoryBot.define do
type_champ 'multiple_drop_down_list'
drop_down_list { create(:drop_down_list) }
end
factory :type_de_champ_linked_drop_down_list, class: 'TypesDeChamp::LinkedDropDownListTypeDeChamp' do
type_champ 'linked_drop_down_list'
drop_down_list { create(:drop_down_list) }
end
factory :type_de_champ_pays, class: 'TypesDeChamp::PaysTypeDeChamp' do
type_champ 'pays'
end