[#1203] Move all tag definitions to mail template concern

Even the one that is mail-specific, because it is too easy to overlook
it when refactoring otherwise
This commit is contained in:
Frederic Merizen 2018-01-18 11:28:31 +01:00
parent eebab14954
commit 943fef3160
2 changed files with 13 additions and 10 deletions

View file

@ -1,8 +1,6 @@
module MailTemplateConcern
extend ActiveSupport::Concern
include Rails.application.routes.url_helpers
include ActionView::Helpers::UrlHelper
include TagsSubstitutionConcern
def subject_for_dossier(dossier)
@ -20,14 +18,7 @@ module MailTemplateConcern
end
end
private
def dossier_tags
super + [{ libelle: 'lien dossier', description: '', lambda: -> (d) { users_dossier_recapitulatif_link(d) } }]
end
def users_dossier_recapitulatif_link(dossier)
url = users_dossier_recapitulatif_url(dossier)
link_to(url, url, target: '_blank')
super + dossier_tags_for_mail
end
end

View file

@ -1,6 +1,9 @@
module TagsSubstitutionConcern
extend ActiveSupport::Concern
include Rails.application.routes.url_helpers
include ActionView::Helpers::UrlHelper
def tags
if procedure.for_individual?
identity_tags = individual_tags
@ -73,6 +76,15 @@ module TagsSubstitutionConcern
end
end
def dossier_tags_for_mail
[{ libelle: 'lien dossier', description: '', lambda: -> (d) { users_dossier_recapitulatif_link(d) } }]
end
def users_dossier_recapitulatif_link(dossier)
url = users_dossier_recapitulatif_url(dossier)
link_to(url, url, target: '_blank')
end
def individual_tags
[
{ libelle: 'civilité', description: 'M., Mme', target: :gender },