#4785 ajout d'une balise 'groupe instructeur'

This commit is contained in:
clemkeirua 2020-02-17 16:32:41 +01:00 committed by GitHub Action
parent c6bfcd5c2f
commit 059d80ea34
2 changed files with 43 additions and 1 deletions

View file

@ -11,6 +11,13 @@ module TagsSubstitutionConcern
target: :motivation,
available_for_states: Dossier::TERMINE
},
{
libelle: 'groupe instructeur',
description: 'Le groupe instructeur en charge du dossier',
lambda: -> (d) { d.groupe_instructeur.label },
available?: -> (d) { d.procedure.routee? },
available_for_states: Dossier::SOUMIS
},
{
libelle: 'date de dépôt',
description: 'Date du passage en construction du dossier par lusager',
@ -219,7 +226,19 @@ module TagsSubstitutionConcern
def replace_tags_with_values_from_data(text, tags, data)
if data.present?
tags.reduce(text) do |acc, tag|
replace_tag(acc, tag, data)
# A tag is available by default.
# If it has an :available? lambda, then we check its result to determine if the tag is available
if tag.key?(:available?)
tag_available = instance_exec(data, &tag[:available?])
else
tag_available = true
end
if tag_available
replace_tag(acc, tag, data)
else
text
end
end
else
text