From 5bbcd600fb5436740f7c369a586d94a3950f083a Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 23 Jul 2019 12:45:44 +0000 Subject: [PATCH] mailers: extract more of the template to partials This will allow to re-use these partials in other emails --- app/views/layouts/mailers/_logo.html.haml | 5 +++ .../layouts/mailers/_service_footer.html.haml | 34 +++++++++++++++ .../layouts/mailers/notification.html.haml | 43 ++----------------- 3 files changed, 42 insertions(+), 40 deletions(-) create mode 100644 app/views/layouts/mailers/_logo.html.haml create mode 100644 app/views/layouts/mailers/_service_footer.html.haml diff --git a/app/views/layouts/mailers/_logo.html.haml b/app/views/layouts/mailers/_logo.html.haml new file mode 100644 index 000000000..2b0aa1ae2 --- /dev/null +++ b/app/views/layouts/mailers/_logo.html.haml @@ -0,0 +1,5 @@ +- if url.present? + %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0" } + %tr + %td{ align: "center" } + = image_tag url, height: "150", style: "display:block; max-height: 150px; max-width: 150px;" diff --git a/app/views/layouts/mailers/_service_footer.html.haml b/app/views/layouts/mailers/_service_footer.html.haml new file mode 100644 index 000000000..c60d887b6 --- /dev/null +++ b/app/views/layouts/mailers/_service_footer.html.haml @@ -0,0 +1,34 @@ +%strong + Merci de ne pas répondre à cet email. + - if dossier.present? && dossier.messagerie_available? + Pour vous adresser à votre administration, passez directement par la + = succeed '.' do + = link_to 'messagerie du dossier', messagerie_dossier_url(dossier), target: '_blank', rel: 'noopener' + +- if service.present? + %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" } + %tr + %td{ width: "50%", valign: "top" } + %p + %strong Cette démarche est gérée par : + %br + = service.nom + %br + = service.organisme + %br + = service.adresse + %td{ width: "50%", valign: "top" } + %p + %strong Poser une question sur votre dossier : + %br + - if dossier.present? && dossier.messagerie_available? + = link_to 'Par la messagerie', messagerie_dossier_url(dossier), target: '_blank', rel: 'noopener' + - else + Par email : + = link_to service.email, "mailto:#{service.email}" + %br + Par téléphone : + = link_to service.telephone, "tel:#{service.telephone}" + %br + Horaires : #{ formatted_horaires(service.horaires) } + diff --git a/app/views/layouts/mailers/notification.html.haml b/app/views/layouts/mailers/notification.html.haml index 04da35e63..ca9f84d73 100644 --- a/app/views/layouts/mailers/notification.html.haml +++ b/app/views/layouts/mailers/notification.html.haml @@ -1,44 +1,7 @@ -- if @logo_url.present? - - content_for :procedure_logo do - %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0" } - %tr - %td{ align: "center" } - = image_tag @logo_url, height: "150", style: "display:block; max-height: 150px; max-width: 150px;" +- content_for :procedure_logo do + = render 'layouts/mailers/logo', url: @logo_url - content_for :footer do - %strong - Merci de ne pas répondre à cet email. - - if @dossier.present? && @dossier.messagerie_available? - Pour vous adresser à votre administration, passez directement par la - = succeed '.' do - = link_to 'messagerie du dossier', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener' - - - if @service.present? - %table{ width: "100%", border: "0", cellspacing: "0", cellpadding: "0", style: "cursor:auto;color:#55575d;font-family:Helvetica, Arial, sans-serif;font-size:11px;line-height:22px;text-align:left;" } - %tr - %td{ width: "50%", valign: "top" } - %p - %strong Cette démarche est gérée par : - %br - = @service.nom - %br - = @service.organisme - %br - = @service.adresse - %td{ width: "50%", valign: "top" } - %p - %strong Poser une question sur votre dossier : - %br - - if @dossier.present? && @dossier.messagerie_available? - = link_to 'Par la messagerie', messagerie_dossier_url(@dossier), target: '_blank', rel: 'noopener' - - else - Par email : - = link_to @service.email, "mailto:#{@service.email}" - %br - Par téléphone : - = link_to @service.telephone, "tel:#{@service.telephone}" - %br - Horaires : #{ formatted_horaires(@service.horaires) } - + = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier = render template: 'layouts/mailers/notifications_layout'