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-09-20 16:21:12 +02:00
|
|
|
@header_sections = if is_private
|
|
|
|
dossier.revision.types_de_champ_private
|
|
|
|
else
|
|
|
|
dossier.revision.types_de_champ_public
|
|
|
|
end.filter(&:header_section?)
|
2024-06-21 05:49:42 +02:00
|
|
|
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
|
2024-09-20 16:21:12 +02:00
|
|
|
"##{header_section.html_id}"
|
2024-06-21 05:49:42 +02:00
|
|
|
end
|
|
|
|
end
|