[#1421] DRY up type de champ toggles
This commit is contained in:
parent
15e8d8af05
commit
d3df6e813c
1 changed files with 8 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue