Merge pull request #2101 from betagouv/frederic/fix_1421-listes_deroulantes_liees

#1421 listes deroulantes liees - step 1
This commit is contained in:
Frederic Merizen 2018-06-21 16:30:17 +02:00 committed by GitHub
commit 5242e125dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 24 additions and 8 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

@ -1,13 +1,16 @@
module TypeDeChampHelper
TOGGLES = {
'piece_justificative' => :champ_pj?,
'siret' => :champ_siret?,
'linked_drop_down_list' => :champ_linked_dropdown?
}
def tdc_options
tdcs = TypeDeChamp.type_de_champs_list_fr
if !Flipflop.champ_pj?
tdcs.reject! { |tdc| tdc.last == "piece_justificative" }
end
if !Flipflop.champ_siret?
tdcs.reject! { |tdc| tdc.last == "siret" }
tdcs.select! do |tdc|
toggle = TOGGLES[tdc.last]
toggle.blank? || Flipflop.send(toggle)
end
tdcs

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

@ -11,6 +11,8 @@ Flipflop.configure do
title: "Champ pièce justificative"
feature :champ_siret,
title: "Champ SIRET"
feature :champ_linked_dropdown,
title: "Champ double menu déroulant"
end
feature :web_hook

View file

@ -17,13 +17,14 @@ fr:
address: 'Adresse'
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'
engagement: 'Engagement'
header_section: 'Titre de section'
explication: 'Explication'
multiple_drop_down_list: 'Menu déroulant à choix multiples'
dossier_link: 'Lien vers un autre dossier'
piece_justificative: 'Pièce justificative'
siret: 'SIRET'

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