move child? method for clarity

This commit is contained in:
Paul Chavard 2024-09-16 17:03:40 +02:00
parent 54132df77d
commit 3fef831524
No known key found for this signature in database
4 changed files with 7 additions and 8 deletions

View file

@ -57,7 +57,7 @@ module DossierChampsConcern
revision
.types_de_champ
.filter { _1.stable_id.in?(stable_ids) }
.filter { !revision.child?(_1) }
.filter { !_1.child?(revision) }
.map { _1.repetition? ? project_champ(_1, nil) : champ_for_update(_1, nil, updated_by: nil) }
end
@ -129,7 +129,7 @@ module DossierChampsConcern
end
def check_valid_row_id?(type_de_champ, row_id)
if revision.child?(type_de_champ)
if type_de_champ.child?(revision)
if row_id.blank?
raise "type_de_champ #{type_de_champ.stable_id} must have a row_id because it is part of a repetition"
end

View file

@ -19,7 +19,7 @@ module DossierSectionsConcern
end
def auto_numbering_section_headers_for?(type_de_champ)
return false if revision.child?(type_de_champ)
return false if type_de_champ.child?(revision)
sections_for(type_de_champ)&.none? { _1.libelle =~ /^\d/ }
end

View file

@ -219,11 +219,6 @@ class ProcedureRevision < ApplicationRecord
.find { _1.type_de_champ_id == tdc.id }.parent&.type_de_champ
end
def child?(tdc)
revision_types_de_champ
.find { _1.type_de_champ_id == tdc.id }&.child?
end
def remove_children_of(tdc)
children_of(tdc).each do |child|
remove_type_de_champ(child.stable_id)

View file

@ -456,6 +456,10 @@ class TypeDeChamp < ApplicationRecord
!private?
end
def child?(revision)
revision.revision_types_de_champ.find { _1.type_de_champ_id == id }&.child?
end
def filename_for_attachement(attachment_sym)
attachment = send(attachment_sym)
if attachment.attached?