demarches-normaliennes/app/components/instructeurs/column_picker_component.rb

17 lines
596 B
Ruby
Raw Normal View History

class Instructeurs::ColumnPickerComponent < ApplicationComponent
attr_reader :procedure, :procedure_presentation
def initialize(procedure:, procedure_presentation:)
@procedure = procedure
@procedure_presentation = procedure_presentation
2024-08-19 14:34:36 +02:00
@displayable_columns_for_select, @displayable_columns_selected = displayable_columns_for_select
end
2024-08-19 14:34:36 +02:00
def displayable_columns_for_select
[
2024-08-19 14:34:36 +02:00
procedure.columns.reject(&:virtual).map { |column| [column.label, column.id] },
procedure_presentation.displayed_fields.map { Column.new(**_1.deep_symbolize_keys).id }
]
end
end