2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-07-22 09:22:05 +02:00
|
|
|
class Instructeurs::ColumnPickerComponent < ApplicationComponent
|
2024-07-20 08:08:23 +02:00
|
|
|
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
|
2024-07-20 08:08:23 +02:00
|
|
|
end
|
|
|
|
|
2024-08-19 14:34:36 +02:00
|
|
|
def displayable_columns_for_select
|
2024-07-20 08:08:23 +02:00
|
|
|
[
|
2024-08-20 18:41:04 +02:00
|
|
|
procedure.columns.filter(&:displayable).map { |column| [column.label, column.id] },
|
2024-10-07 21:46:59 +02:00
|
|
|
procedure_presentation.displayed_fields.map { Column.new(**_1.deep_symbolize_keys.merge(procedure_id: procedure.id)).id }
|
2024-07-20 08:08:23 +02:00
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|