refactor(attestation): unspecified_champs_for_dossier based on types_de_champ
This commit is contained in:
parent
54926db89b
commit
a474cf4590
1 changed files with 4 additions and 4 deletions
|
@ -87,13 +87,13 @@ class AttestationTemplate < ApplicationRecord
|
|||
end
|
||||
|
||||
def unspecified_champs_for_dossier(dossier)
|
||||
champs_by_stable_id = dossier.champs_for_revision(root: true).index_by { "tdc#{_1.stable_id}" }
|
||||
types_de_champ_by_tag_id = dossier.revision.types_de_champ.index_by { "tdc#{_1.stable_id}" }
|
||||
|
||||
used_tags.filter_map do |used_tag|
|
||||
corresponding_champ = champs_by_stable_id[used_tag]
|
||||
corresponding_type_de_champ = types_de_champ_by_tag_id[used_tag]
|
||||
|
||||
if corresponding_champ && corresponding_champ.blank?
|
||||
corresponding_champ
|
||||
if corresponding_type_de_champ && dossier.project_champ(corresponding_type_de_champ, nil).blank?
|
||||
corresponding_type_de_champ
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue