[Fix #3064] Add a preview button for state notifications emails
This commit is contained in:
parent
e91b412254
commit
14c3fb7224
4 changed files with 39 additions and 0 deletions
|
@ -0,0 +1,33 @@
|
||||||
|
module NewAdministrateur
|
||||||
|
class MailTemplatesController < AdministrateurController
|
||||||
|
include ActionView::Helpers::SanitizeHelper
|
||||||
|
|
||||||
|
def preview
|
||||||
|
@procedure = procedure
|
||||||
|
mail_template = find_mail_template_by_slug(params[:id])
|
||||||
|
@dossier = Dossier.new(id: 0)
|
||||||
|
|
||||||
|
render(html: sanitize(mail_template.body), layout: 'mailers/notification')
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def procedure
|
||||||
|
@procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def mail_templates
|
||||||
|
[
|
||||||
|
@procedure.initiated_mail_template,
|
||||||
|
@procedure.received_mail_template,
|
||||||
|
@procedure.closed_mail_template,
|
||||||
|
@procedure.refused_mail_template,
|
||||||
|
@procedure.without_continuation_mail_template
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_mail_template_by_slug(slug)
|
||||||
|
mail_templates.find { |template| template.class.const_get(:SLUG) == slug }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -15,6 +15,7 @@
|
||||||
.text-right
|
.text-right
|
||||||
= link_to "Annuler", admin_procedure_mail_templates_path(@procedure), class: "btn btn-default"
|
= link_to "Annuler", admin_procedure_mail_templates_path(@procedure), class: "btn btn-default"
|
||||||
= f.button :submit, 'Mettre à jour', class: "btn-success"
|
= f.button :submit, 'Mettre à jour', class: "btn-success"
|
||||||
|
= link_to "Prévisualiser", preview_procedure_mail_template_path(@procedure, @mail_template.class.const_get(:SLUG)), class: "btn btn-primary", target: "_blank"
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
|
|
@ -378,6 +378,10 @@ Rails.application.routes.draw do
|
||||||
patch :move
|
patch :move
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :mail_templates, only: [] do
|
||||||
|
get 'preview', on: :member
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :services, except: [:show] do
|
resources :services, except: [:show] do
|
||||||
|
|
|
@ -10,6 +10,7 @@ describe 'admin/mail_templates/edit.html.haml', type: :view do
|
||||||
allow(view).to receive(:admin_procedure_mail_templates_path).and_return("/toto")
|
allow(view).to receive(:admin_procedure_mail_templates_path).and_return("/toto")
|
||||||
|
|
||||||
assign(:mail_template, mail_template)
|
assign(:mail_template, mail_template)
|
||||||
|
assign(:procedure, procedure)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "Champs are listed in the page" do
|
context "Champs are listed in the page" do
|
||||||
|
|
Loading…
Reference in a new issue