inject options_for_select for linked_drop_down_column
This commit is contained in:
parent
9e5713f470
commit
49d3661441
3 changed files with 7 additions and 10 deletions
|
@ -3,7 +3,7 @@
|
|||
class Columns::LinkedDropDownColumn < Columns::ChampColumn
|
||||
attr_reader :path
|
||||
|
||||
def initialize(procedure_id:, label:, stable_id:, tdc_type:, path:, displayable:, type: :text)
|
||||
def initialize(procedure_id:, label:, stable_id:, tdc_type:, path:, options_for_select: [], displayable:, type: :text)
|
||||
@path = path
|
||||
|
||||
super(
|
||||
|
@ -12,7 +12,8 @@ class Columns::LinkedDropDownColumn < Columns::ChampColumn
|
|||
stable_id:,
|
||||
tdc_type:,
|
||||
displayable:,
|
||||
type:
|
||||
type:,
|
||||
options_for_select:
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -558,12 +558,6 @@ class TypeDeChamp < ApplicationRecord
|
|||
APIGeoService.departements.map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] }
|
||||
elsif region?
|
||||
APIGeoService.regions.map { [_1[:name], _1[:code]] }
|
||||
elsif linked_drop_down_list?
|
||||
if column.path == :primary
|
||||
primary_options
|
||||
else
|
||||
secondary_options.values.flatten
|
||||
end
|
||||
elsif choice_type?
|
||||
if drop_down_list?
|
||||
drop_down_options
|
||||
|
|
|
@ -89,7 +89,8 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
|||
label: "#{libelle_with_prefix(prefix)} (Primaire)",
|
||||
type: :enum,
|
||||
path: :primary,
|
||||
displayable: false
|
||||
displayable: false,
|
||||
options_for_select: primary_options
|
||||
),
|
||||
Columns::LinkedDropDownColumn.new(
|
||||
procedure_id: procedure.id,
|
||||
|
@ -98,7 +99,8 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
|||
label: "#{libelle_with_prefix(prefix)} (Secondaire)",
|
||||
type: :enum,
|
||||
path: :secondary,
|
||||
displayable: false
|
||||
displayable: false,
|
||||
options_for_select: secondary_options.values.flatten.uniq.sort
|
||||
)
|
||||
]
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue