[#1421] DRY up type de champ toggles

This commit is contained in:
Frederic Merizen 2018-06-14 15:22:47 +02:00
parent 15e8d8af05
commit d3df6e813c

View file

@ -1,13 +1,15 @@
module TypeDeChampHelper
TOGGLES = {
'piece_justificative' => :champ_pj?,
'siret' => :champ_siret?
}
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