2019-03-14 14:58:01 +01:00
|
|
|
module NewAdministrateur
|
|
|
|
class MailTemplatesController < AdministrateurController
|
|
|
|
include ActionView::Helpers::SanitizeHelper
|
|
|
|
|
2020-08-06 16:32:51 +02:00
|
|
|
def index
|
|
|
|
@mail_templates = mail_templates
|
|
|
|
end
|
|
|
|
|
2019-03-14 14:58:01 +01:00
|
|
|
def preview
|
2019-07-23 15:26:55 +02:00
|
|
|
mail_template = find_mail_template_by_slug(params[:id])
|
|
|
|
dossier = Dossier.new(id: '1', procedure: procedure)
|
|
|
|
|
|
|
|
@dossier = dossier
|
2019-08-20 11:28:07 +02:00
|
|
|
@logo_url = procedure.logo_url
|
2019-03-21 15:39:37 +01:00
|
|
|
@service = procedure.service
|
2019-07-22 15:49:11 +02:00
|
|
|
@rendered_template = sanitize(mail_template.body)
|
2019-07-23 15:26:55 +02:00
|
|
|
@actions = mail_template.actions_for_dossier(dossier)
|
2019-03-14 14:58:01 +01:00
|
|
|
|
2019-07-22 15:49:11 +02:00
|
|
|
render(template: 'notification_mailer/send_notification', layout: 'mailers/notifications_layout')
|
2019-03-14 14:58:01 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def procedure
|
2019-07-23 15:26:55 +02:00
|
|
|
@procedure ||= current_administrateur.procedures.find(params[:procedure_id])
|
2019-03-14 14:58:01 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def mail_templates
|
|
|
|
[
|
2019-07-23 15:26:55 +02:00
|
|
|
procedure.initiated_mail_template,
|
|
|
|
procedure.received_mail_template,
|
|
|
|
procedure.closed_mail_template,
|
|
|
|
procedure.refused_mail_template,
|
|
|
|
procedure.without_continuation_mail_template
|
2019-03-14 14:58:01 +01:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def find_mail_template_by_slug(slug)
|
|
|
|
mail_templates.find { |template| template.class.const_get(:SLUG) == slug }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|