2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-06-21 05:49:42 +02:00
|
|
|
class ViewableChamp::HeaderSectionsSummaryComponent < ApplicationComponent
|
2024-06-27 12:46:15 +02:00
|
|
|
attr_reader :header_sections
|
|
|
|
|
2024-06-21 05:49:42 +02:00
|
|
|
def initialize(dossier:, is_private:)
|
|
|
|
@dossier = dossier
|
|
|
|
@is_private = is_private
|
|
|
|
|
2024-06-27 12:46:15 +02:00
|
|
|
@header_sections = @dossier.revision
|
2024-06-21 05:49:42 +02:00
|
|
|
.types_de_champ_for(scope: @is_private ? :private : :public)
|
|
|
|
.filter(&:header_section?)
|
|
|
|
.map { @dossier.project_champ(_1, nil) } # row_id not needed, do not link to repetiion header_sections
|
|
|
|
end
|
|
|
|
|
2024-06-27 12:46:15 +02:00
|
|
|
def render? = header_sections.any?
|
|
|
|
|
2024-06-21 05:49:42 +02:00
|
|
|
def href(header_section) # used by viewable champs to anchor elements
|
|
|
|
"##{header_section.input_group_id}"
|
|
|
|
end
|
|
|
|
end
|