diff --git a/app/controllers/templates_preferences_controller.rb b/app/controllers/templates_preferences_controller.rb index 24aedbd4..7e358537 100644 --- a/app/controllers/templates_preferences_controller.rb +++ b/app/controllers/templates_preferences_controller.rb @@ -22,7 +22,7 @@ class TemplatesPreferencesController < ApplicationController preferences: %i[bcc_completed request_email_subject request_email_body documents_copy_email_subject documents_copy_email_body documents_copy_email_enabled documents_copy_email_attach_audit - documents_copy_email_attach_documents + documents_copy_email_attach_documents documents_copy_email_reply_to completed_notification_email_attach_documents completed_redirect_url submitters_order diff --git a/app/mailers/submitter_mailer.rb b/app/mailers/submitter_mailer.rb index 81773261..2441b165 100644 --- a/app/mailers/submitter_mailer.rb +++ b/app/mailers/submitter_mailer.rb @@ -121,7 +121,7 @@ class SubmitterMailer < ApplicationMailer @body ||= @email_config.value['body'] if @email_config assign_message_metadata('submitter_documents_copy', @submitter) - reply_to = build_submitter_reply_to(submitter) + reply_to = build_submitter_reply_to(submitter, email_config: @email_config, documents_copy_email: true) I18n.with_locale(@current_account.locale) do subject = @@ -140,8 +140,10 @@ class SubmitterMailer < ApplicationMailer private - def build_submitter_reply_to(submitter) + def build_submitter_reply_to(submitter, email_config: nil, documents_copy_email: nil) reply_to = submitter.preferences['reply_to'].presence + reply_to ||= submitter.template.preferences['documents_copy_email_reply_to'].presence if documents_copy_email + reply_to ||= email_config.value['reply_to'].presence if email_config if reply_to.blank? && (submitter.submission.created_by_user || submitter.template.author)&.email != submitter.email reply_to = (submitter.submission.created_by_user || submitter.template.author)&.friendly_name&.sub(/\+\w+@/, '@') diff --git a/app/views/personalization_settings/_documents_copy_email_form.html.erb b/app/views/personalization_settings/_documents_copy_email_form.html.erb index 6b9e0fc3..fcb3b18a 100644 --- a/app/views/personalization_settings/_documents_copy_email_form.html.erb +++ b/app/views/personalization_settings/_documents_copy_email_form.html.erb @@ -8,7 +8,7 @@
<%= form_for AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY), url: settings_personalization_path, method: :post, html: { autocomplete: 'off', class: 'space-y-4' } do |f| %> <%= f.hidden_field :key %> - <%= f.fields_for :value, Struct.new(:subject, :body, :attach_audit_log, :attach_documents).new(*f.object.value.values_at('subject', 'body', 'attach_audit_log', 'attach_documents')) do |ff| %> + <%= f.fields_for :value, Struct.new(:subject, :body, :reply_to, :attach_audit_log, :attach_documents).new(*f.object.value.values_at('subject', 'body', 'reply_to', 'attach_audit_log', 'attach_documents')) do |ff| %>
<%= ff.label :subject, t('subject'), class: 'label' %> <%= ff.text_field :subject, required: true, class: 'base-input', dir: 'auto' %> @@ -24,6 +24,12 @@ <%= ff.text_area :body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
+ <% if can?(:manage, :reply_to) %> +
+ <%= ff.label :reply_to, t('reply_to'), class: 'label' %> + <%= ff.email_field :reply_to, class: 'base-input', dir: 'auto', placeholder: t(:email) %> +
+ <% end %>
<%= t('attach_documents') %> diff --git a/app/views/templates_preferences/show.html.erb b/app/views/templates_preferences/show.html.erb index 1cf56287..1a99e638 100644 --- a/app/views/templates_preferences/show.html.erb +++ b/app/views/templates_preferences/show.html.erb @@ -118,7 +118,7 @@ <%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %> <% configs = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY).value %> - <%= f.fields_for :preferences, Struct.new(:documents_copy_email_subject, :documents_copy_email_body, :documents_copy_email_enabled, :documents_copy_email_attach_audit, :documents_copy_email_attach_documents).new(@template.preferences['documents_copy_email_subject'].presence || configs['subject'], @template.preferences['documents_copy_email_body'].presence || configs['body'], @template.preferences['documents_copy_email_enabled'], configs['attach_audit_log'] != false && @template.preferences['documents_copy_email_attach_audit'] != false, configs['attach_documents'] != false && @template.preferences['documents_copy_email_attach_documents'] != false) do |ff| %> + <%= f.fields_for :preferences, Struct.new(:documents_copy_email_reply_to, :documents_copy_email_subject, :documents_copy_email_body, :documents_copy_email_enabled, :documents_copy_email_attach_audit, :documents_copy_email_attach_documents).new(@template.preferences['documents_copy_email_reply_to'].presence || configs['reply_to'], @template.preferences['documents_copy_email_subject'].presence || configs['subject'], @template.preferences['documents_copy_email_body'].presence || configs['body'], @template.preferences['documents_copy_email_enabled'], configs['attach_audit_log'] != false && @template.preferences['documents_copy_email_attach_audit'] != false, configs['attach_documents'] != false && @template.preferences['documents_copy_email_attach_documents'] != false) do |ff| %>
<%= ff.label :documents_copy_email_subject, t('email_subject'), class: 'label' %> <%= ff.text_field :documents_copy_email_subject, required: true, class: 'base-input', dir: 'auto' %> @@ -134,6 +134,12 @@ <%= ff.text_area :documents_copy_email_body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
+ <% if can?(:manage, :reply_to) %> +
+ <%= ff.label :documents_copy_email_reply_to, t('reply_to'), class: 'label' %> + <%= ff.email_field :documents_copy_email_reply_to, class: 'base-input', dir: 'auto', placeholder: t(:email) %> +
+ <% end %>
<%= t('attach_documents_to_the_email') %> diff --git a/config/locales/i18n.yml b/config/locales/i18n.yml index 351a58f4..acd0d6e1 100644 --- a/config/locales/i18n.yml +++ b/config/locales/i18n.yml @@ -20,6 +20,7 @@ en: &en language_ko: 한국어 hi_there: Hi there thanks: Thanks + reply_to: Reply to pending_by_me: Pending by me partially_completed: Partially completed unarchive: Unarchive @@ -720,6 +721,7 @@ en: &en read: Read your data es: &es + reply_to: Responder a partially_completed: Parcialmente completado pending_by_me: Pendiente por mi add: Agregar @@ -1422,6 +1424,7 @@ es: &es read: Leer tus datos it: &it + reply_to: Rispondi a pending_by_me: In sospeso da me add: Aggiungi adding: Aggiungendo @@ -2123,6 +2126,7 @@ it: &it read: Leggi i tuoi dati fr: &fr + reply_to: Répondre à partially_completed: Partiellement complété pending_by_me: En attente par moi add: Ajouter @@ -2826,6 +2830,7 @@ fr: &fr read: Lire vos données pt: &pt + reply_to: Responder a partially_completed: Parcialmente concluído pending_by_me: Pendente por mim add: Adicionar @@ -3528,6 +3533,7 @@ pt: &pt read: Ler seus dados de: &de + reply_to: Antworten auf partially_completed: Teilweise abgeschlossen pending_by_me: Ausstehend von mir add: Hinzufügen