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

View file

@ -1,6 +1,9 @@
module TagsSubstitutionConcern module TagsSubstitutionConcern
extend ActiveSupport::Concern extend ActiveSupport::Concern
include Rails.application.routes.url_helpers
include ActionView::Helpers::UrlHelper
def tags def tags
if procedure.for_individual? if procedure.for_individual?
identity_tags = individual_tags identity_tags = individual_tags
@ -73,6 +76,15 @@ module TagsSubstitutionConcern
end end
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 def individual_tags
[ [
{ libelle: 'civilité', description: 'M., Mme', target: :gender }, { libelle: 'civilité', description: 'M., Mme', target: :gender },