fix(dossier): do not show repetitions in header sections summary

This commit is contained in:
Paul Chavard 2024-09-20 16:21:12 +02:00
parent 6254b50de9
commit 3429a72f53
No known key found for this signature in database
6 changed files with 83 additions and 7 deletions

View file

@ -7,15 +7,16 @@ class ViewableChamp::HeaderSectionsSummaryComponent < ApplicationComponent
@dossier = dossier
@is_private = is_private
@header_sections = @dossier.revision
.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
@header_sections = if is_private
dossier.revision.types_de_champ_private
else
dossier.revision.types_de_champ_public
end.filter(&:header_section?)
end
def render? = header_sections.any?
def href(header_section) # used by viewable champs to anchor elements
"##{header_section.input_group_id}"
"##{header_section.html_id}"
end
end

View file

@ -262,7 +262,7 @@ class Champ < ApplicationRecord
end
def html_id
"champ-#{public_id}"
type_de_champ.html_id(row_id)
end
def needs_dossier_id?

View file

@ -13,7 +13,7 @@ class ProcedureRevisionTypeDeChamp < ApplicationRecord
scope :public_only, -> { joins(:type_de_champ).where(types_de_champ: { private: false }) }
scope :private_only, -> { joins(:type_de_champ).where(types_de_champ: { private: true }) }
delegate :stable_id, :libelle, :description, :type_champ, :mandatory?, :private?, :to_typed_id, to: :type_de_champ
delegate :stable_id, :libelle, :description, :type_champ, :header_section?, :mandatory?, :private?, :to_typed_id, to: :type_de_champ
def child?
parent_id.present?

View file

@ -763,6 +763,10 @@ class TypeDeChamp < ApplicationRecord
end
end
def html_id(row_id = nil)
"champ-#{public_id(row_id)}"
end
private
def populate_stable_id