move options_for_select from champ_column to column
This commit is contained in:
parent
f8dc1d1533
commit
f5227f9609
3 changed files with 7 additions and 8 deletions
|
@ -58,10 +58,8 @@ class Instructeurs::ColumnFilterValueComponent < ApplicationComponent
|
|||
Procedure.find(procedure_id).labels.filter_map do
|
||||
[_1.name, _1.id]
|
||||
end
|
||||
elsif column.is_a?(Columns::ChampColumn)
|
||||
column.options_for_select
|
||||
else
|
||||
[]
|
||||
column.options_for_select
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ class Column
|
|||
|
||||
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
|
||||
@table = table
|
||||
@column = column
|
||||
|
@ -20,6 +20,7 @@ class Column
|
|||
@value_column = value_column
|
||||
@filterable = filterable
|
||||
@displayable = displayable
|
||||
@options_for_select = options_for_select
|
||||
end
|
||||
|
||||
# the id is a String to be used in forms
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
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: [])
|
||||
@stable_id = stable_id
|
||||
@tdc_type = tdc_type
|
||||
@options_for_select = options_for_select
|
||||
|
||||
super(
|
||||
procedure_id:,
|
||||
|
@ -16,7 +15,8 @@ class Columns::ChampColumn < Column
|
|||
type:,
|
||||
value_column:,
|
||||
displayable:,
|
||||
filterable:
|
||||
filterable:,
|
||||
options_for_select:
|
||||
)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue