move options_for_select from champ_column to column

This commit is contained in:
simon lehericey 2024-11-06 13:48:47 +01:00
parent f8dc1d1533
commit f5227f9609
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
3 changed files with 7 additions and 8 deletions

View file

@ -58,10 +58,8 @@ class Instructeurs::ColumnFilterValueComponent < ApplicationComponent
Procedure.find(procedure_id).labels.filter_map do Procedure.find(procedure_id).labels.filter_map do
[_1.name, _1.id] [_1.name, _1.id]
end end
elsif column.is_a?(Columns::ChampColumn)
column.options_for_select
else else
[] column.options_for_select
end end
end end

View file

@ -8,9 +8,9 @@ class Column
TYPE_DE_CHAMP_TABLE = 'type_de_champ' TYPE_DE_CHAMP_TABLE = 'type_de_champ'
attr_reader :table, :column, :label, :type, :scope, :value_column, :filterable, :displayable attr_reader :table, :column, :label, :type, :scope, :value_column, :filterable, :displayable, :options_for_select
def initialize(procedure_id:, table:, column:, label: nil, type: :text, value_column: :value, filterable: true, displayable: true, scope: '') def initialize(procedure_id:, table:, column:, label: nil, type: :text, value_column: :value, filterable: true, displayable: true, scope: '', options_for_select: [])
@procedure_id = procedure_id @procedure_id = procedure_id
@table = table @table = table
@column = column @column = column
@ -20,6 +20,7 @@ class Column
@value_column = value_column @value_column = value_column
@filterable = filterable @filterable = filterable
@displayable = displayable @displayable = displayable
@options_for_select = options_for_select
end end
# the id is a String to be used in forms # the id is a String to be used in forms

View file

@ -1,12 +1,11 @@
# frozen_string_literal: true # frozen_string_literal: true
class Columns::ChampColumn < Column class Columns::ChampColumn < Column
attr_reader :stable_id, :options_for_select attr_reader :stable_id
def initialize(procedure_id:, label:, stable_id:, tdc_type:, displayable: true, filterable: true, type: :text, value_column: :value, options_for_select: []) def initialize(procedure_id:, label:, stable_id:, tdc_type:, displayable: true, filterable: true, type: :text, value_column: :value, options_for_select: [])
@stable_id = stable_id @stable_id = stable_id
@tdc_type = tdc_type @tdc_type = tdc_type
@options_for_select = options_for_select
super( super(
procedure_id:, procedure_id:,
@ -16,7 +15,8 @@ class Columns::ChampColumn < Column
type:, type:,
value_column:, value_column:,
displayable:, displayable:,
filterable: filterable:,
options_for_select:
) )
end end