demarches-normaliennes/app/components/editable_champ/header_section_component.rb
simon lehericey e64ac79f05 tech(refactor): much nicer code, thx LeSim
root -> rooted_tree

depth_cach -> walk

smal refactor

comment

remove form for header_section

remove seen_at from header section

header_section: champ -> header_section

champ_subree: remove if not

remove root_depth use header_section_level_value instead

remove unused include

remove ChampTreeComponent

rename ChampsSubtreeComponent to SectionComponent

use TreeableConcern only in section component

remove fields_for_champ_component

champs -> tail

add split_section_champ helper

refactor(editable_champ::header_section): keep same interface everywhere

fix(repetition): add spec for SectionComponent on repetitions
2023-04-20 08:22:02 +02:00

24 lines
458 B
Ruby

class EditableChamp::HeaderSectionComponent < ApplicationComponent
def initialize(form: nil, champ:, seen_at: nil)
@champ = champ
end
def level
@champ.level
end
def libelle
@champ.libelle
end
def header_section_classnames
class_names = ["fr-h#{level}"]
class_names << 'header-section' if @champ.dossier.auto_numbering_section_headers_for?(@champ)
class_names
end
def tag_for_depth
"h#{level + 1}"
end
end