inject options_for_select for linked_drop_down_column

This commit is contained in:
simon lehericey 2024-11-06 12:02:53 +01:00
parent 9e5713f470
commit 49d3661441
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
3 changed files with 7 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -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