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
|
class Columns::LinkedDropDownColumn < Columns::ChampColumn
|
||||||
attr_reader :path
|
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
|
@path = path
|
||||||
|
|
||||||
super(
|
super(
|
||||||
|
@ -12,7 +12,8 @@ class Columns::LinkedDropDownColumn < Columns::ChampColumn
|
||||||
stable_id:,
|
stable_id:,
|
||||||
tdc_type:,
|
tdc_type:,
|
||||||
displayable:,
|
displayable:,
|
||||||
type:
|
type:,
|
||||||
|
options_for_select:
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -558,12 +558,6 @@ class TypeDeChamp < ApplicationRecord
|
||||||
APIGeoService.departements.map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] }
|
APIGeoService.departements.map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] }
|
||||||
elsif region?
|
elsif region?
|
||||||
APIGeoService.regions.map { [_1[:name], _1[:code]] }
|
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?
|
elsif choice_type?
|
||||||
if drop_down_list?
|
if drop_down_list?
|
||||||
drop_down_options
|
drop_down_options
|
||||||
|
|
|
@ -89,7 +89,8 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
||||||
label: "#{libelle_with_prefix(prefix)} (Primaire)",
|
label: "#{libelle_with_prefix(prefix)} (Primaire)",
|
||||||
type: :enum,
|
type: :enum,
|
||||||
path: :primary,
|
path: :primary,
|
||||||
displayable: false
|
displayable: false,
|
||||||
|
options_for_select: primary_options
|
||||||
),
|
),
|
||||||
Columns::LinkedDropDownColumn.new(
|
Columns::LinkedDropDownColumn.new(
|
||||||
procedure_id: procedure.id,
|
procedure_id: procedure.id,
|
||||||
|
@ -98,7 +99,8 @@ class TypesDeChamp::LinkedDropDownListTypeDeChamp < TypesDeChamp::TypeDeChampBas
|
||||||
label: "#{libelle_with_prefix(prefix)} (Secondaire)",
|
label: "#{libelle_with_prefix(prefix)} (Secondaire)",
|
||||||
type: :enum,
|
type: :enum,
|
||||||
path: :secondary,
|
path: :secondary,
|
||||||
displayable: false
|
displayable: false,
|
||||||
|
options_for_select: secondary_options.values.flatten.uniq.sort
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue