diff --git a/app/models/concerns/tags_substitution_concern.rb b/app/models/concerns/tags_substitution_concern.rb index 898ad8f5b..ea3414544 100644 --- a/app/models/concerns/tags_substitution_concern.rb +++ b/app/models/concerns/tags_substitution_concern.rb @@ -167,15 +167,11 @@ module TagsSubstitutionConcern end def types_de_champ_tags(types_de_champ, available_for_states) - types_de_champ.flat_map do |tdc| - [ - { - libelle: tdc.libelle, - description: tdc.description, - available_for_states: available_for_states - } - ] + tags = types_de_champ.flat_map(&:tags_for_template) + tags.each do |tag| + tag[:available_for_states] = available_for_states end + tags end def replace_tags(text, dossier) diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 1b167c67a..d7faa2904 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -174,6 +174,15 @@ class TypeDeChamp < ApplicationRecord end end + def tags_for_template + [ + { + libelle: libelle, + description: description + } + ] + end + private def setup_procedure