Show section numbers only if none of sections start with numbers
This commit is contained in:
parent
f77285ded6
commit
4feda01b6f
2 changed files with 15 additions and 4 deletions
|
@ -22,6 +22,20 @@ class Champs::HeaderSectionChamp < Champ
|
|||
# The user cannot enter any information here so it doesn’t make much sense to search
|
||||
end
|
||||
|
||||
def libelle_with_section_index
|
||||
if libelle_with_section_index? || siblings.any?(&:libelle_with_section_index?)
|
||||
libelle
|
||||
else
|
||||
"#{section_index}. #{libelle}"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def libelle_with_section_index?
|
||||
libelle =~ /^\d/
|
||||
end
|
||||
|
||||
def section_index
|
||||
siblings
|
||||
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:header_section) }
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
%h2.header-section
|
||||
- libelle_starts_with_number = (champ.libelle =~ /^\d/)
|
||||
- if !libelle_starts_with_number
|
||||
= "#{champ.section_index}."
|
||||
= champ.libelle
|
||||
= champ.libelle_with_section_index
|
||||
|
|
Loading…
Reference in a new issue