effective_resources 2.11.6 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df20052518286a1ff3271eddb3e9007211d31ac6702cc4bb87ddf0c6706a0a31
4
- data.tar.gz: 15b0d4740305154619c1cf4922ed567811149c60966d63d2c737c6306a2b8e1c
3
+ metadata.gz: c9a944e2514ae76e234dac891c9b4dac6487d8c34c8abbb342d7fe3147a8eee5
4
+ data.tar.gz: 69d7a8dc18db8bcbbc3952eb951e06dfaa032d1a88e079875d50927a5ac65cea
5
5
  SHA512:
6
- metadata.gz: eccffe9230dd0ee3119e04c48cc8b05374d73d29ca18c7d5344c7d6be3cf39362622cadf17265b0f146773bd0be3dd77276b5988832d82c641c8c0f1f348a4c7
7
- data.tar.gz: ab946a0050800cab2698955c69cdd27911ec110f7a68dacd19ef975b7800e2eadd1145c456f660d775b3f985d4e1e6a9f62776363191d78fae68f08ea0e81bb9
6
+ metadata.gz: a10b2b3935a059132988291d1fabda1140674df15467da8ae4a37e335629af3d1205c9b313825e7ad9036a953f3b46137a8a3de1b4dda3f57daee134c7d6321d
7
+ data.tar.gz: 41c2edb6b2cd4eea3cbffaed992605251458208d2a9933a28624d88c084081d66efd151d69dd13acab3f1ba2d8e9729faf86ef09770337795958eba49ee8b857
@@ -13,15 +13,25 @@ module EffectiveActsAsEmailFormHelper
13
13
  action.kind_of?(Effective::EmailTemplate) ? action : Effective::EmailTemplate.where(template_name: action).first!
14
14
  end
15
15
 
16
- # These defaults are only used when there is no email_template
17
- email_defaults = form.object.email_form_defaults(action) unless email_template.present?
16
+ if email_template.present?
17
+ resource.email_form_from ||= email_template.from
18
+ resource.email_form_subject ||= email_template.subject
19
+ resource.email_form_body ||= email_template.body
20
+ else
21
+ defaults = form.object.email_form_defaults(action)
22
+
23
+ resource.email_form_from ||= defaults[:from]
24
+ resource.email_form_subject ||= defaults[:subject]
25
+ resource.email_form_body ||= defaults[:body]
26
+ end
27
+
28
+ resource.email_form_from ||= EffectiveResources.mailer_froms.first
18
29
 
19
30
  locals = {
20
31
  form: form,
21
32
  email_to: to,
22
33
  email_skip: skip,
23
34
  email_action: (action || true),
24
- email_defaults: email_defaults,
25
35
  email_template: email_template,
26
36
  email_variables: variables
27
37
  }
@@ -4,24 +4,12 @@
4
4
  = form.check_box :email_form_skip, label: 'Do not send email'
5
5
 
6
6
  = form.hide_if :email_form_skip, true do
7
- - if email_to.present? && form.respond_to?(:static_field)
8
- = form.static_field :email_form_to, label: 'To', value: (email_to.respond_to?(:email) ? email_to.email : email_to)
7
+ - if email_to.present?
8
+ = form.static_field :email_form_to, label: 'To', value: (email_to.try(:email) || email_to)
9
9
 
10
- - if form.object.errors.present?
11
- = form.text_field :email_form_from, label: 'From'
12
- = form.text_field :email_form_subject, label: 'Subject'
13
- = form.text_area :email_form_body, label: 'Body', rows: 10
14
-
15
- - elsif email_template.present?
16
- -# email_template is an Effective::EmailTemplate
17
- = form.text_field :email_form_from, label: 'From', value: email_template.from
18
- = form.text_field :email_form_subject, label: 'Subject', value: email_template.subject
19
- = form.text_area :email_form_body, label: 'Body', value: email_template.body, rows: 10
20
-
21
- - else
22
- = form.text_field :email_form_from, label: 'From', value: (email_defaults[:from] || '')
23
- = form.text_field :email_form_subject, label: 'Subject', value: (email_defaults[:subject] || '')
24
- = form.text_area :email_form_body, label: 'Body', rows: 10, value: (email_defaults[:body] || '')
10
+ = form.select :email_form_from, EffectiveResources.mailer_froms, label: 'From'
11
+ = form.text_field :email_form_subject, label: 'Subject'
12
+ = form.text_area :email_form_body, label: 'Body', rows: 10
25
13
 
26
14
  - if email_variables.present?
27
15
  %p The available variables are:
@@ -30,4 +18,4 @@
30
18
  - email_variables.each do |variable|
31
19
  %li {{ #{variable} }}
32
20
 
33
- %small.text-muted Only a developer can add additional variables
21
+ %small.text-muted Please contact us to add additional variables
@@ -49,6 +49,10 @@ EffectiveResources.setup do |config|
49
49
  # Default From
50
50
  config.mailer_sender = '"Info" <info@example.com>'
51
51
 
52
+ # Default Froms radios collection
53
+ # Used for effective gems email collection. Leave blank to fallback to just the mailer_sender
54
+ config.mailer_froms = ['"Info" <info@example.com>', '"Admin" <admin@example.com>']
55
+
52
56
  # Send Admin correspondence To
53
57
  config.mailer_admin = '"Admin" <admin@example.com>'
54
58
  end
@@ -7,7 +7,7 @@ module EffectiveGem
7
7
 
8
8
  EXCLUDED_GETTERS = [
9
9
  :config, :setup, :send_email, :parent_mailer_class,
10
- :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject
10
+ :deliver_method, :mailer_layout, :mailer_sender, :mailer_froms, :mailer_admin, :mailer_subject
11
11
  ]
12
12
 
13
13
  included do
@@ -70,6 +70,10 @@ module EffectiveGem
70
70
  config[:mailer_sender].presence || EffectiveResources.mailer_sender
71
71
  end
72
72
 
73
+ def mailer_froms
74
+ config[:mailer_froms].presence || EffectiveResources.mailer_froms
75
+ end
76
+
73
77
  def mailer_admin
74
78
  config[:mailer_admin].presence || EffectiveResources.mailer_admin
75
79
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.11.6'.freeze
2
+ VERSION = '2.12.0'.freeze
3
3
  end
@@ -10,7 +10,7 @@ module EffectiveResources
10
10
  def self.config_keys
11
11
  [
12
12
  :authorization_method, :default_submits,
13
- :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject
13
+ :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_froms, :mailer_admin, :mailer_subject
14
14
  ]
15
15
  end
16
16
 
@@ -60,12 +60,16 @@ module EffectiveResources
60
60
  config[:mailer_subject] || MAILER_SUBJECT_PROC
61
61
  end
62
62
 
63
+ def self.mailer_admin
64
+ config[:mailer_admin] || raise('effective resources mailer_admin missing. Add it to config/initializers/effective_resources.rb')
65
+ end
66
+
63
67
  def self.mailer_sender
64
68
  config[:mailer_sender] || raise('effective resources mailer_sender missing. Add it to config/initializers/effective_resources.rb')
65
69
  end
66
70
 
67
- def self.mailer_admin
68
- config[:mailer_admin] || raise('effective resources mailer_admin missing. Add it to config/initializers/effective_resources.rb')
71
+ def self.mailer_froms
72
+ config[:mailer_froms].presence || [mailer_sender]
69
73
  end
70
74
 
71
75
  # Utilities
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.6
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2023-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails