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

View file

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

View file

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