Merge pull request #6049 from tchak/improuve-title-numbers
Show section numbers only if none of sections start with numbers
This commit is contained in:
commit
233f51e8ca
4 changed files with 23 additions and 7 deletions
|
@ -45,6 +45,7 @@ class Champ < ApplicationRecord
|
||||||
:repetition?,
|
:repetition?,
|
||||||
:dossier_link?,
|
:dossier_link?,
|
||||||
:titre_identite?,
|
:titre_identite?,
|
||||||
|
:header_section?,
|
||||||
to: :type_de_champ
|
to: :type_de_champ
|
||||||
|
|
||||||
scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) }
|
scope :updated_since?, -> (date) { where('champs.updated_at > ?', date) }
|
||||||
|
@ -86,6 +87,10 @@ class Champ < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sections
|
||||||
|
siblings.filter(&:header_section?)
|
||||||
|
end
|
||||||
|
|
||||||
def mandatory_and_blank?
|
def mandatory_and_blank?
|
||||||
mandatory? && blank?
|
mandatory? && blank?
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,9 +22,19 @@ class Champs::HeaderSectionChamp < Champ
|
||||||
# The user cannot enter any information here so it doesn’t make much sense to search
|
# The user cannot enter any information here so it doesn’t make much sense to search
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def libelle_with_section_index
|
||||||
|
if sections.none?(&:libelle_with_section_index?)
|
||||||
|
"#{section_index}. #{libelle}"
|
||||||
|
else
|
||||||
|
libelle
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def libelle_with_section_index?
|
||||||
|
libelle =~ /^\d/
|
||||||
|
end
|
||||||
|
|
||||||
def section_index
|
def section_index
|
||||||
siblings
|
sections.index(self) + 1
|
||||||
.filter { |c| c.type_champ == TypeDeChamp.type_champs.fetch(:header_section) }
|
|
||||||
.index(self) + 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -174,6 +174,10 @@ class TypeDeChamp < ApplicationRecord
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def header_section?
|
||||||
|
type_champ == TypeDeChamp.type_champs.fetch(:header_section)
|
||||||
|
end
|
||||||
|
|
||||||
def linked_drop_down_list?
|
def linked_drop_down_list?
|
||||||
type_champ == TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
|
type_champ == TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,2 @@
|
||||||
%h2.header-section
|
%h2.header-section
|
||||||
- libelle_starts_with_number = (champ.libelle =~ /^\d/)
|
= champ.libelle_with_section_index
|
||||||
- if !libelle_starts_with_number
|
|
||||||
= "#{champ.section_index}."
|
|
||||||
= champ.libelle
|
|
||||||
|
|
Loading…
Reference in a new issue