From 0f957ec77bc720baf97abf4bbaa5d8884d09e786 Mon Sep 17 00:00:00 2001 From: pedong Date: Wed, 17 Jul 2019 18:41:07 +0200 Subject: [PATCH 01/13] [fixe #3974] add message for invite mail --- app/controllers/invites_controller.rb | 1 + app/views/invite_mailer/invite_guest.html.haml | 3 +++ app/views/invite_mailer/invite_user.html.haml | 3 +++ app/views/invites/_form.html.haml | 9 +++++++-- db/migrate/20190717151228_add_message_to_invites.rb | 5 +++++ 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20190717151228_add_message_to_invites.rb diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 6304dbe3e..646c3505c 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -12,6 +12,7 @@ class InvitesController < ApplicationController dossier: dossier, user: User.find_by(email: email), email: email, + message: params[:invite_message], email_sender: current_user.email ) diff --git a/app/views/invite_mailer/invite_guest.html.haml b/app/views/invite_mailer/invite_guest.html.haml index 2b30029d2..55dc79820 100644 --- a/app/views/invite_mailer/invite_guest.html.haml +++ b/app/views/invite_mailer/invite_guest.html.haml @@ -8,6 +8,9 @@ %strong= @invite.dossier.procedure.libelle sur demarches-simplifiees.fr. +%p + = @invite.message + %p Cette plateforme permet à ses utilisateurs d'établir des dossiers 100 % en ligne et de dialoguer avec plusieurs interlocuteurs privilégiés avant d'instruire un dépot. diff --git a/app/views/invite_mailer/invite_user.html.haml b/app/views/invite_mailer/invite_user.html.haml index 4497d69f7..8f5fa7b85 100644 --- a/app/views/invite_mailer/invite_user.html.haml +++ b/app/views/invite_mailer/invite_user.html.haml @@ -6,6 +6,9 @@ = @invite.email_sender souhaite que vous participiez à l'élaboration d'un dossier sur demarches-simplifiees.fr. +%p + = @invite.message + %p Pour le consulter, merci de suivre ce lien : - url_for_link = invite_url(@invite) diff --git a/app/views/invites/_form.html.haml b/app/views/invites/_form.html.haml index a35dbe5f9..422bfa55a 100644 --- a/app/views/invites/_form.html.haml +++ b/app/views/invites/_form.html.haml @@ -13,5 +13,10 @@ %p Cette personne aura le droit de modifier votre dossier. = form_tag dossier_invites_path(dossier), remote: true, method: :post, class: 'form' do - = email_field_tag :invite_email, '', class: 'small', placeholder: 'adresse email', required: true - = submit_tag 'Envoyer une invitation', class: 'button accepted' + .row + .col + = email_field_tag :invite_email, '', class: 'small', placeholder: 'adresse email', required: true + .col + = text_area_tag :invite_message, '', class: 'small', placeholder: 'message' + .col + = submit_tag 'Envoyer une invitation', class: 'button accepted' diff --git a/db/migrate/20190717151228_add_message_to_invites.rb b/db/migrate/20190717151228_add_message_to_invites.rb new file mode 100644 index 000000000..dae608b19 --- /dev/null +++ b/db/migrate/20190717151228_add_message_to_invites.rb @@ -0,0 +1,5 @@ +class AddMessageToInvites < ActiveRecord::Migration[5.2] + def change + add_column :invites, :message, :text + end +end From 4a0873c5af5ea1198a259b4268d94907377f3cd3 Mon Sep 17 00:00:00 2001 From: pedong Date: Tue, 23 Jul 2019 19:05:56 +0200 Subject: [PATCH 02/13] add quote show the message invite --- app/views/invite_mailer/invite_guest.html.haml | 6 ++++-- app/views/invite_mailer/invite_user.html.haml | 6 ++++-- app/views/layouts/mailers/layout.html.erb | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/invite_mailer/invite_guest.html.haml b/app/views/invite_mailer/invite_guest.html.haml index 55dc79820..a8dcd7cbe 100644 --- a/app/views/invite_mailer/invite_guest.html.haml +++ b/app/views/invite_mailer/invite_guest.html.haml @@ -8,8 +8,10 @@ %strong= @invite.dossier.procedure.libelle sur demarches-simplifiees.fr. -%p - = @invite.message +- if @invite.message.present? + %blockquote + %p + = @invite.message %p Cette plateforme permet à ses utilisateurs d'établir des dossiers 100 % en ligne et de dialoguer avec plusieurs interlocuteurs privilégiés avant d'instruire un dépot. diff --git a/app/views/invite_mailer/invite_user.html.haml b/app/views/invite_mailer/invite_user.html.haml index 8f5fa7b85..f3eb91022 100644 --- a/app/views/invite_mailer/invite_user.html.haml +++ b/app/views/invite_mailer/invite_user.html.haml @@ -6,8 +6,10 @@ = @invite.email_sender souhaite que vous participiez à l'élaboration d'un dossier sur demarches-simplifiees.fr. -%p - = @invite.message +- if @invite.message.present? + %blockquote + %p + = @invite.message %p Pour le consulter, merci de suivre ce lien : diff --git a/app/views/layouts/mailers/layout.html.erb b/app/views/layouts/mailers/layout.html.erb index 373c10142..71d0c744b 100644 --- a/app/views/layouts/mailers/layout.html.erb +++ b/app/views/layouts/mailers/layout.html.erb @@ -9,7 +9,7 @@ - + From 14192916f194f22c20b5d086d0649316875ee81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chai=CC=88b=20Martinez?= Date: Wed, 17 Jul 2019 17:39:45 +0200 Subject: [PATCH 03/13] Add edit dossier link [fix #4114] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Chaïb Martinez --- app/views/invites/_dropdown.html.haml | 2 +- .../users/dossiers/_dossier_actions.html.haml | 14 ++++++++++++++ app/views/users/dossiers/demande.html.haml | 2 +- app/views/users/dossiers/show/_header.html.haml | 5 +++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/views/invites/_dropdown.html.haml b/app/views/invites/_dropdown.html.haml index 368c359ef..869804b53 100644 --- a/app/views/invites/_dropdown.html.haml +++ b/app/views/invites/_dropdown.html.haml @@ -1,4 +1,4 @@ -%span.dropdown.invite-user-action +%span.dropdown.invite-user-action{ :style => "float:right;right: 10px;" } %button.button.dropdown-button %span.icon.person - if dossier.invites.count > 0 diff --git a/app/views/users/dossiers/_dossier_actions.html.haml b/app/views/users/dossiers/_dossier_actions.html.haml index cc9cc58ed..bad0197ba 100644 --- a/app/views/users/dossiers/_dossier_actions.html.haml +++ b/app/views/users/dossiers/_dossier_actions.html.haml @@ -9,6 +9,20 @@ Actions .dropdown-content.fade-in-down %ul.dropdown-items + - if !dossier.read_only? + - if dossier.brouillon? + %li + = link_to(url_for_dossier(dossier)) do + %span.icon.edit + .dropdown-description + Modifier le brouillon + - else + %li + = link_to modifier_dossier_path(dossier) do + %span.icon.edit + .dropdown-description + Modifier le dossier + - if has_new_dossier_action %li = link_to procedure_lien(dossier.procedure) do diff --git a/app/views/users/dossiers/demande.html.haml b/app/views/users/dossiers/demande.html.haml index b4050b41d..0d7ce1898 100644 --- a/app/views/users/dossiers/demande.html.haml +++ b/app/views/users/dossiers/demande.html.haml @@ -10,5 +10,5 @@ .container - if !@dossier.read_only? - = link_to "Modifier le dossier", modifier_dossier_path(@dossier), class: 'button primary edit-form' + = link_to "Modifier le dossier", modifier_dossier_path(@dossier), class: 'button accepted edit-form', 'title'=> "Vous pouvez modifier votre dossier tant qu'il n'est passé en instruction" .clearfix diff --git a/app/views/users/dossiers/show/_header.html.haml b/app/views/users/dossiers/show/_header.html.haml index e1d488610..8753abecb 100644 --- a/app/views/users/dossiers/show/_header.html.haml +++ b/app/views/users/dossiers/show/_header.html.haml @@ -11,8 +11,9 @@ = "- Déposé le #{l(dossier.en_construction_at, format: '%d %B %Y')}" - if current_user.owns?(dossier) - .header-actions - = render partial: 'invites/dropdown', locals: { dossier: dossier } + = link_to "Modifier mon dossier", modifier_dossier_path(dossier.id), class: 'button accepted edit-form', 'title'=> "Vous pouvez modifier votre dossier tant qu'il n'est passé en instruction" + = render partial: 'invites/dropdown', locals: { dossier: dossier } + .clearfix %ul.tabs = dynamic_tab_item('Résumé', dossier_path(dossier)) From 079ac3da339875555faad35a8d45b2a9ca2ee0b0 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Wed, 24 Jul 2019 10:28:45 +0200 Subject: [PATCH 04/13] invite: signal that the message is optional --- app/views/invites/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/invites/_form.html.haml b/app/views/invites/_form.html.haml index 422bfa55a..7936bc7ce 100644 --- a/app/views/invites/_form.html.haml +++ b/app/views/invites/_form.html.haml @@ -17,6 +17,6 @@ .col = email_field_tag :invite_email, '', class: 'small', placeholder: 'adresse email', required: true .col - = text_area_tag :invite_message, '', class: 'small', placeholder: 'message' + = text_area_tag :invite_message, '', class: 'small', placeholder: 'Ajouter un message à la personne invitée (optionnel)' .col = submit_tag 'Envoyer une invitation', class: 'button accepted' From a9708bff5d4977a658f1fbf6a4eb1b2cccd8bb3b Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Wed, 24 Jul 2019 15:26:23 +0200 Subject: [PATCH 05/13] ajout d'infos pratiques pour aller chercher son siret --- app/views/users/dossiers/siret.html.haml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/users/dossiers/siret.html.haml b/app/views/users/dossiers/siret.html.haml index 4f0f25283..955f7e160 100644 --- a/app/views/users/dossiers/siret.html.haml +++ b/app/views/users/dossiers/siret.html.haml @@ -6,6 +6,11 @@ %p.mb-1 Merci de remplir le numéro de SIRET de votre entreprise, administration ou association pour commencer la démarche. + %p.mb-1 + Pour trouver votre numéro SIRET, utilisez + %a{ href: 'https://entreprise.data.gouv.fr/', target: '_blank', rel: 'noopener' } + entreprise.data.gouv.fr + ou renseignez-vous auprès de votre service comptable = f.label :siret, style: "display: none" = f.text_field :siret, placeholder: "Numéro SIRET à 14 chiffres", required: true From 2ff6958ad6764158d64f0716d67c8b7a323d6054 Mon Sep 17 00:00:00 2001 From: clemkeirua Date: Thu, 25 Jul 2019 11:33:29 +0200 Subject: [PATCH 06/13] better spacing --- app/assets/stylesheets/new_design/helpers.scss | 4 ++++ app/views/users/dossiers/siret.html.haml | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/new_design/helpers.scss b/app/assets/stylesheets/new_design/helpers.scss index 189bd8252..e6500b579 100644 --- a/app/assets/stylesheets/new_design/helpers.scss +++ b/app/assets/stylesheets/new_design/helpers.scss @@ -7,3 +7,7 @@ .mr-1 { margin-right: $default-spacer; } + +.mb-4 { + margin-bottom: 4 * $default-spacer; +} diff --git a/app/views/users/dossiers/siret.html.haml b/app/views/users/dossiers/siret.html.haml index 955f7e160..62735fd09 100644 --- a/app/views/users/dossiers/siret.html.haml +++ b/app/views/users/dossiers/siret.html.haml @@ -6,14 +6,14 @@ %p.mb-1 Merci de remplir le numéro de SIRET de votre entreprise, administration ou association pour commencer la démarche. - %p.mb-1 + = f.label :siret, style: "display: none" + = f.text_field :siret, placeholder: "Numéro SIRET à 14 chiffres", required: true + = f.hidden_field :dossier_id, value: @dossier.id + + %p.mb-4 Pour trouver votre numéro SIRET, utilisez %a{ href: 'https://entreprise.data.gouv.fr/', target: '_blank', rel: 'noopener' } entreprise.data.gouv.fr - ou renseignez-vous auprès de votre service comptable - = f.label :siret, style: "display: none" - = f.text_field :siret, placeholder: "Numéro SIRET à 14 chiffres", required: true + ou renseignez-vous auprès de votre service comptable. - = f.hidden_field :dossier_id, value: @dossier.id - - = f.submit "Valider", class: "button large primary expand", data: { disable_with: "Récupération des informations…" } + = f.submit "Valider", class: "button large primary expand mt-1", data: { disable_with: "Récupération des informations…" } From 3abb0a1c442f72845cff7062968b6222592bde7a Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 18 Jul 2019 16:03:28 +0200 Subject: [PATCH 07/13] helpers: prevent information leakage from round_button links --- app/views/shared/_mailer_round_button.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_mailer_round_button.html.haml b/app/views/shared/_mailer_round_button.html.haml index 18031f176..c983e0bdc 100644 --- a/app/views/shared/_mailer_round_button.html.haml +++ b/app/views/shared/_mailer_round_button.html.haml @@ -5,5 +5,5 @@ %table{ border:"0", cellspacing:"0", cellpadding:"0", style:"margin: auto" } %tr %td{ align:"center", style:"border-radius: 5px;", bgcolor:"#0069cc" } - %a{ href: url, target:"_blank", style:"font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; text-decoration: none; border-radius: 5px; padding: 12px 25px; border: 1px solid #0069cc; display: inline-block;" } + %a{ href: url, target:"_blank", rel: "noopener", style:"font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; text-decoration: none; border-radius: 5px; padding: 12px 25px; border: 1px solid #0069cc; display: inline-block;" } = text From 2c612f644813290257e5ae0ebf8d8d8533c9e22a Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 22 Jul 2019 15:11:03 +0200 Subject: [PATCH 08/13] helpers: add variants to mailer_round_button --- app/helpers/mailer_helper.rb | 23 +++++++++++++++++-- .../notify_new_answer.html.haml | 2 +- .../shared/_mailer_round_button.html.haml | 11 +++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index 28767841d..3c0bd9f55 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -1,5 +1,24 @@ module MailerHelper - def round_button(text, url) - render 'shared/mailer_round_button', text: text, url: url + def round_button(text, url, variant) + render 'shared/mailer_round_button', text: text, url: url, theme: theme(variant) + end + + private + + def theme(variant) + case variant + when :primary + { color: white, bg_color: blue, border_color: blue } + when :secondary + { color: blue, bg_color: white, border_color: blue } + end + end + + def blue + '#0069CC' + end + + def white + '#FFFFFF' end end diff --git a/app/views/dossier_mailer/notify_new_answer.html.haml b/app/views/dossier_mailer/notify_new_answer.html.haml index 3e0195afe..a1b910b82 100644 --- a/app/views/dossier_mailer/notify_new_answer.html.haml +++ b/app/views/dossier_mailer/notify_new_answer.html.haml @@ -11,7 +11,7 @@ %p Pour le consulter et y répondre, cliquez sur le bouton ci-dessous : -= round_button('Lire le message', messagerie_dossier_url(@dossier)) += round_button('Lire le message', messagerie_dossier_url(@dossier), :primary) = render 'layouts/mailers/signature', service: @service diff --git a/app/views/shared/_mailer_round_button.html.haml b/app/views/shared/_mailer_round_button.html.haml index c983e0bdc..012479f2f 100644 --- a/app/views/shared/_mailer_round_button.html.haml +++ b/app/views/shared/_mailer_round_button.html.haml @@ -1,9 +1,10 @@ /# From https://litmus.com/blog/a-guide-to-bulletproof-buttons-in-email-design -%table{ width: "100%", border: "0", cellspacing:"0", cellpadding:"0" } +%table{ width: "100%", border: "0", cellspacing:"0", cellpadding:"5" } %tr - %td - %table{ border:"0", cellspacing:"0", cellpadding:"0", style:"margin: auto" } + %td{ align: "center" } + %table{ border:"0", cellspacing:"0", cellpadding:"0" } %tr - %td{ align:"center", style:"border-radius: 5px;", bgcolor:"#0069cc" } - %a{ href: url, target:"_blank", rel: "noopener", style:"font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; text-decoration: none; border-radius: 5px; padding: 12px 25px; border: 1px solid #0069cc; display: inline-block;" } + %td{ align:"center", style:"border-radius: 5px;", color: theme[:color], bgcolor: theme[:bg_color] } + %a{ href: url, target:"_blank", rel: "noopener", style:"font-size: 16px; font-family: Helvetica, Arial, sans-serif; color: #{theme[:color]}; text-decoration: none; text-decoration: none; border-radius: 5px; padding: 12px 25px; border: 1px solid #{theme[:border_color]}; display: inline-block; min-width: 250px" } = text + From 45c62cefb21e13734471e43f30d86dbff1a83660 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 22 Jul 2019 15:20:47 +0200 Subject: [PATCH 09/13] helpers: add vertical_margin helper for mailers --- app/helpers/mailer_helper.rb | 4 ++++ app/views/shared/_mailer_vertical_margin.html.haml | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 app/views/shared/_mailer_vertical_margin.html.haml diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index 3c0bd9f55..e653e703c 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -1,4 +1,8 @@ module MailerHelper + def vertical_margin(height) + render 'shared/mailer_vertical_margin', height: height + end + def round_button(text, url, variant) render 'shared/mailer_round_button', text: text, url: url, theme: theme(variant) end diff --git a/app/views/shared/_mailer_vertical_margin.html.haml b/app/views/shared/_mailer_vertical_margin.html.haml new file mode 100644 index 000000000..9af4339db --- /dev/null +++ b/app/views/shared/_mailer_vertical_margin.html.haml @@ -0,0 +1,4 @@ +%table{ cellspacing: "0", cellpadding: (height / 2), border: "0" } + %tr + %td + %div From 6195ee41f3af9d27d355942880f6bc526a303013 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 22 Jul 2019 15:13:47 +0000 Subject: [PATCH 10/13] mailers: add CTA to `new_draft` email --- app/views/dossier_mailer/notify_new_draft.html.haml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/dossier_mailer/notify_new_draft.html.haml b/app/views/dossier_mailer/notify_new_draft.html.haml index fc22af857..93c8afcd1 100644 --- a/app/views/dossier_mailer/notify_new_draft.html.haml +++ b/app/views/dossier_mailer/notify_new_draft.html.haml @@ -5,13 +5,16 @@ Bonjour, %p - Vous avez commencé à remplir un dossier pour la démarche « #{@dossier.procedure.libelle} ». + Vous avez commencé à remplir un dossier pour la démarche + = succeed '.' do + %strong « #{@dossier.procedure.libelle} » %p Vous pouvez %strong retrouver et compléter votre dossier - à l’adresse suivante : - = link_to dossier_url(@dossier), dossier_url(@dossier), target: '_blank', rel: 'noopener' + en cliquant sur le bouton ci-dessous: + += round_button('Afficher votre dossier', dossier_url(@dossier), :primary) = render 'layouts/mailers/signature' From 8313752663178860d2df463e5737d51a190c7a83 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 22 Jul 2019 13:21:05 +0000 Subject: [PATCH 11/13] mailers: add CTA to templated emails --- app/mailers/notification_mailer.rb | 2 ++ app/models/concerns/mail_template_concern.rb | 10 ++++++++++ app/models/mails/refused_mail.rb | 4 ++++ app/views/notification_mailer/_actions.html.haml | 13 +++++++++++++ .../notification_mailer/send_notification.html.haml | 3 +++ spec/mailers/notification_mailer_spec.rb | 5 +++++ 6 files changed, 37 insertions(+) create mode 100644 app/views/notification_mailer/_actions.html.haml diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 816ff2c7c..5ec6cc596 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -9,6 +9,7 @@ class NotificationMailer < ApplicationMailer include ActionView::Helpers::SanitizeHelper helper ServiceHelper + helper MailerHelper layout 'mailers/notifications_layout' @@ -46,6 +47,7 @@ class NotificationMailer < ApplicationMailer @service = dossier.procedure.service @logo_url = attach_logo(dossier.procedure) @rendered_template = sanitize(body) + @actions = mail_template.actions_for_dossier(dossier) mail(subject: subject, to: email, template_name: 'send_notification') end diff --git a/app/models/concerns/mail_template_concern.rb b/app/models/concerns/mail_template_concern.rb index 3b613eb2b..f720c8297 100644 --- a/app/models/concerns/mail_template_concern.rb +++ b/app/models/concerns/mail_template_concern.rb @@ -3,6 +3,12 @@ module MailTemplateConcern include TagsSubstitutionConcern + module Actions + SHOW = :show + ASK_QUESTION = :ask_question + REPLY = :reply + end + def subject_for_dossier(dossier) replace_tags(subject, dossier) end @@ -11,6 +17,10 @@ module MailTemplateConcern replace_tags(body, dossier) end + def actions_for_dossier(dossier) + [MailTemplateConcern::Actions::SHOW, MailTemplateConcern::Actions::ASK_QUESTION] + end + def update_rich_body self.rich_body = self.body end diff --git a/app/models/mails/refused_mail.rb b/app/models/mails/refused_mail.rb index ad598d859..375b94326 100644 --- a/app/models/mails/refused_mail.rb +++ b/app/models/mails/refused_mail.rb @@ -9,5 +9,9 @@ module Mails DISPLAYED_NAME = 'Accusé de rejet du dossier' DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- a été refusé (--libellé démarche--)' DOSSIER_STATE = Dossier.states.fetch(:refuse) + + def actions_for_dossier(dossier) + [MailTemplateConcern::Actions::REPLY, MailTemplateConcern::Actions::SHOW] + end end end diff --git a/app/views/notification_mailer/_actions.html.haml b/app/views/notification_mailer/_actions.html.haml new file mode 100644 index 000000000..f6ccd9130 --- /dev/null +++ b/app/views/notification_mailer/_actions.html.haml @@ -0,0 +1,13 @@ += vertical_margin(15) + +- actions.each_with_index do |action, index| + - variant = (index == 0 ? :primary : :secondary) + - case action + - when MailTemplateConcern::Actions::SHOW + = round_button('Consulter mon dossier', dossier_url(@dossier), variant) + - when MailTemplateConcern::Actions::ASK_QUESTION + = round_button('J’ai une question', messagerie_dossier_url(@dossier), variant) + - when MailTemplateConcern::Actions::REPLY + = round_button('Répondre à ce message', messagerie_dossier_url(@dossier), variant) + += vertical_margin(8) diff --git a/app/views/notification_mailer/send_notification.html.haml b/app/views/notification_mailer/send_notification.html.haml index 875806f48..6ce7aa565 100644 --- a/app/views/notification_mailer/send_notification.html.haml +++ b/app/views/notification_mailer/send_notification.html.haml @@ -3,5 +3,8 @@ = @rendered_template +- if @actions.present? + = render 'notification_mailer/actions', actions: @actions, dossier: @dossier + - content_for :footer do = render 'layouts/mailers/service_footer', service: @service, dossier: @dossier diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 4d28508b9..da2c13a7f 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -28,6 +28,11 @@ RSpec.describe NotificationMailer, type: :mailer do expect(mail.body).to have_link('messagerie') end + it 'renders the actions' do + expect(mail.body).to have_link('Consulter mon dossier', href: dossier_url(dossier)) + expect(mail.body).to have_link('J’ai une question', href: messagerie_dossier_url(dossier)) + end + context 'when the template body contains tags' do let(:email_template) { create(:received_mail, subject: 'Email subject', body: 'Hello --nom--, your dossier --lien dossier-- was processed.') } From 1c837eb9011651b49971d3cae7d6a92b0fd08b16 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 23 Jul 2019 12:59:57 +0000 Subject: [PATCH 12/13] mailers: improve wording of transactional emails and default templates --- app/models/mails/initiated_mail.rb | 2 +- app/models/mails/received_mail.rb | 2 +- app/views/dossier_mailer/notify_new_answer.html.haml | 7 ++++--- .../default_templates/closed_mail.html.haml | 4 +++- .../closed_mail_with_attestation.html.haml | 7 +++---- .../default_templates/initiated_mail.html.haml | 8 ++++---- .../default_templates/received_mail.html.haml | 6 +++++- .../default_templates/refused_mail.html.haml | 6 ++++-- .../without_continuation_mail.html.haml | 4 +++- spec/mailers/previews/notification_mailer_preview.rb | 11 ++++++----- 10 files changed, 34 insertions(+), 23 deletions(-) diff --git a/app/models/mails/initiated_mail.rb b/app/models/mails/initiated_mail.rb index 9653b8d8c..da087942f 100644 --- a/app/models/mails/initiated_mail.rb +++ b/app/models/mails/initiated_mail.rb @@ -7,7 +7,7 @@ module Mails SLUG = "initiated_mail" DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/initiated_mail" DISPLAYED_NAME = 'Accusé de réception' - DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- a bien été reçu (--libellé démarche--)' + DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- a bien été déposé (--libellé démarche--)' DOSSIER_STATE = Dossier.states.fetch(:en_construction) end end diff --git a/app/models/mails/received_mail.rb b/app/models/mails/received_mail.rb index 8e1c73b24..603d12be8 100644 --- a/app/models/mails/received_mail.rb +++ b/app/models/mails/received_mail.rb @@ -7,7 +7,7 @@ module Mails SLUG = "received_mail" DEFAULT_TEMPLATE_NAME = "notification_mailer/default_templates/received_mail" DISPLAYED_NAME = 'Accusé de passage en instruction' - DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- va être instruit (--libellé démarche--)' + DEFAULT_SUBJECT = 'Votre dossier nº --numéro du dossier-- va être examiné (--libellé démarche--)' DOSSIER_STATE = Dossier.states.fetch(:en_instruction) end end diff --git a/app/views/dossier_mailer/notify_new_answer.html.haml b/app/views/dossier_mailer/notify_new_answer.html.haml index a1b910b82..4db0e9270 100644 --- a/app/views/dossier_mailer/notify_new_answer.html.haml +++ b/app/views/dossier_mailer/notify_new_answer.html.haml @@ -5,11 +5,12 @@ Bonjour, %p - L’administration en charge de votre dossier vous a - %strong envoyé un nouveau message. + Vous avez reçu un + %strong nouveau message + de la part du service en charge de votre dossier. %p - Pour le consulter et y répondre, cliquez sur le bouton ci-dessous : + Pour consulter le message et y répondre, cliquez sur le bouton ci-dessous : = round_button('Lire le message', messagerie_dossier_url(@dossier), :primary) diff --git a/app/views/notification_mailer/default_templates/closed_mail.html.haml b/app/views/notification_mailer/default_templates/closed_mail.html.haml index 8af4e8e82..f32359535 100644 --- a/app/views/notification_mailer/default_templates/closed_mail.html.haml +++ b/app/views/notification_mailer/default_templates/closed_mail.html.haml @@ -2,7 +2,9 @@ Bonjour, %p - Votre dossier nº --numéro du dossier-- a été accepté le --date de décision--. + Votre dossier nº --numéro du dossier-- + %strong a été accepté + le --date de décision--. %p À tout moment, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier-- diff --git a/app/views/notification_mailer/default_templates/closed_mail_with_attestation.html.haml b/app/views/notification_mailer/default_templates/closed_mail_with_attestation.html.haml index 1c95b1ca7..277f8af7b 100644 --- a/app/views/notification_mailer/default_templates/closed_mail_with_attestation.html.haml +++ b/app/views/notification_mailer/default_templates/closed_mail_with_attestation.html.haml @@ -2,12 +2,11 @@ Bonjour, %p - Votre dossier nº --numéro du dossier-- a été accepté le --date de décision--. + Votre dossier nº --numéro du dossier-- + %strong a été accepté + le --date de décision--. %p Vous pouvez télécharger votre attestation à l'adresse suivante : --lien attestation-- -%p - À tout moment, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier-- - = render partial: "notification_mailer/default_templates/signature" diff --git a/app/views/notification_mailer/default_templates/initiated_mail.html.haml b/app/views/notification_mailer/default_templates/initiated_mail.html.haml index de2c1c91a..ab8d4a6c7 100644 --- a/app/views/notification_mailer/default_templates/initiated_mail.html.haml +++ b/app/views/notification_mailer/default_templates/initiated_mail.html.haml @@ -2,9 +2,9 @@ Bonjour, %p - Votre administration vous confirme la bonne réception de votre dossier nº --numéro du dossier--. - -%p - À tout moment, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier-- + Votre dossier nº --numéro du dossier-- + = succeed '.' do + %strong a bien été déposé + Si besoin est, vous pouvez encore y apporter des modifications. = render partial: "notification_mailer/default_templates/signature" diff --git a/app/views/notification_mailer/default_templates/received_mail.html.haml b/app/views/notification_mailer/default_templates/received_mail.html.haml index 234d1b1fe..17d82f9df 100644 --- a/app/views/notification_mailer/default_templates/received_mail.html.haml +++ b/app/views/notification_mailer/default_templates/received_mail.html.haml @@ -2,6 +2,10 @@ Bonjour, %p - Votre administration vous confirme la bonne réception de votre dossier nº --numéro du dossier--. Celui-ci sera instruit dans le délai légal déclaré par votre interlocuteur. + Votre dossier nº --numéro du dossier-- + a bien été reçu et + = succeed '.' do + %strong pris en charge + Il va maintenant être examiné par le service. = render partial: "notification_mailer/default_templates/signature" diff --git a/app/views/notification_mailer/default_templates/refused_mail.html.haml b/app/views/notification_mailer/default_templates/refused_mail.html.haml index 5cf09152f..2d7ef0bb3 100644 --- a/app/views/notification_mailer/default_templates/refused_mail.html.haml +++ b/app/views/notification_mailer/default_templates/refused_mail.html.haml @@ -2,10 +2,12 @@ Bonjour, %p - Votre dossier nº --numéro du dossier-- a été refusé le --date de décision--. + Votre dossier nº --numéro du dossier-- + %strong a été refusé + le --date de décision--. %p - Le motif de refus est le suivant : --motivation--. + Le motif de refus est le suivant : « --motivation-- ». %p Pour en savoir plus sur le motif du refus, vous pouvez consulter votre dossier et les éventuels messages de l'administration à cette adresse : --lien dossier-- diff --git a/app/views/notification_mailer/default_templates/without_continuation_mail.html.haml b/app/views/notification_mailer/default_templates/without_continuation_mail.html.haml index 731d65f08..429980e6b 100644 --- a/app/views/notification_mailer/default_templates/without_continuation_mail.html.haml +++ b/app/views/notification_mailer/default_templates/without_continuation_mail.html.haml @@ -2,7 +2,9 @@ Bonjour, %p - Votre dossier nº --numéro du dossier-- a été classé sans suite le --date de décision--. + Votre dossier nº --numéro du dossier-- + %strong a été classé sans suite + le --date de décision--. %p Le motif est le suivant : --motivation--. diff --git a/spec/mailers/previews/notification_mailer_preview.rb b/spec/mailers/previews/notification_mailer_preview.rb index 064d5471d..dff8bbed9 100644 --- a/spec/mailers/previews/notification_mailer_preview.rb +++ b/spec/mailers/previews/notification_mailer_preview.rb @@ -1,19 +1,20 @@ class NotificationMailerPreview < ActionMailer::Preview - def send_dossier_received - NotificationMailer.send_dossier_received(Dossier.last) - end - def send_initiated_notification p = Procedure.where(id: Mails::InitiatedMail.where("body like ?", "% Date: Tue, 23 Jul 2019 13:26:55 +0000 Subject: [PATCH 13/13] admin: display CTA buttons in emails preview --- .../mail_templates_controller.rb | 20 ++++++++++--------- .../notification_mailer/_actions.html.haml | 4 ++-- .../mail_templates_controller_spec.rb | 14 ++++++++++--- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/controllers/new_administrateur/mail_templates_controller.rb b/app/controllers/new_administrateur/mail_templates_controller.rb index 32039afa3..b747f9681 100644 --- a/app/controllers/new_administrateur/mail_templates_controller.rb +++ b/app/controllers/new_administrateur/mail_templates_controller.rb @@ -3,12 +3,14 @@ module NewAdministrateur include ActionView::Helpers::SanitizeHelper def preview - @procedure = procedure + mail_template = find_mail_template_by_slug(params[:id]) + dossier = Dossier.new(id: '1', procedure: procedure) + + @dossier = dossier @logo_url = procedure.logo.url @service = procedure.service - - mail_template = find_mail_template_by_slug(params[:id]) @rendered_template = sanitize(mail_template.body) + @actions = mail_template.actions_for_dossier(dossier) render(template: 'notification_mailer/send_notification', layout: 'mailers/notifications_layout') end @@ -16,16 +18,16 @@ module NewAdministrateur private def procedure - @procedure = current_administrateur.procedures.find(params[:procedure_id]) + @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 + procedure.initiated_mail_template, + procedure.received_mail_template, + procedure.closed_mail_template, + procedure.refused_mail_template, + procedure.without_continuation_mail_template ] end diff --git a/app/views/notification_mailer/_actions.html.haml b/app/views/notification_mailer/_actions.html.haml index f6ccd9130..7bf754962 100644 --- a/app/views/notification_mailer/_actions.html.haml +++ b/app/views/notification_mailer/_actions.html.haml @@ -1,4 +1,4 @@ -= vertical_margin(15) += vertical_margin(12) - actions.each_with_index do |action, index| - variant = (index == 0 ? :primary : :secondary) @@ -10,4 +10,4 @@ - when MailTemplateConcern::Actions::REPLY = round_button('Répondre à ce message', messagerie_dossier_url(@dossier), variant) -= vertical_margin(8) += vertical_margin(5) diff --git a/spec/controllers/new_administrateur/mail_templates_controller_spec.rb b/spec/controllers/new_administrateur/mail_templates_controller_spec.rb index 2a8673f77..365abe78b 100644 --- a/spec/controllers/new_administrateur/mail_templates_controller_spec.rb +++ b/spec/controllers/new_administrateur/mail_templates_controller_spec.rb @@ -13,9 +13,17 @@ describe NewAdministrateur::MailTemplatesController, type: :controller do it { expect(response).to have_http_status(:ok) } - it { expect(response.body).to have_css("img[src*='#{procedure.logo.filename}']") } + it 'displays the procedure logo' do + expect(response.body).to have_css("img[src*='#{procedure.logo.filename}']") + end - it { expect(response.body).to include(procedure.service.nom) } - it { expect(response.body).to include(procedure.service.telephone) } + it 'displays the action buttons' do + expect(response.body).to have_link('Consulter mon dossier') + end + + it 'displays the service in the footer' do + expect(response.body).to include(procedure.service.nom) + expect(response.body).to include(procedure.service.telephone) + end end end