effective_resources 2.11.6 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df20052518286a1ff3271eddb3e9007211d31ac6702cc4bb87ddf0c6706a0a31
4
- data.tar.gz: 15b0d4740305154619c1cf4922ed567811149c60966d63d2c737c6306a2b8e1c
3
+ metadata.gz: 9f4283f3c4e59e72313277c4e8a132c9bcb35fb9250fbd140733c53c2e74d18b
4
+ data.tar.gz: ec11d262fa2bb76d6cea5e31b9445da37fc1c89d4721c89465d07b2bef9ef6bc
5
5
  SHA512:
6
- metadata.gz: eccffe9230dd0ee3119e04c48cc8b05374d73d29ca18c7d5344c7d6be3cf39362622cadf17265b0f146773bd0be3dd77276b5988832d82c641c8c0f1f348a4c7
7
- data.tar.gz: ab946a0050800cab2698955c69cdd27911ec110f7a68dacd19ef975b7800e2eadd1145c456f660d775b3f985d4e1e6a9f62776363191d78fae68f08ea0e81bb9
6
+ metadata.gz: fce12caba2beddbabbd580ddfc9a75e1bc0e0b3827a1bba509141764856953df8015e44f489e872d5cb2cde6b093d527e9823be0d273b984c771a443d8211ee6
7
+ data.tar.gz: ec4a712e9c30fd1ba87c019b8bf98861cdcddb236e8b0872f45f83fa6ea3b01102fdc2030a0d3a92cc2cace7829b0123f6dd042042dd6da08c7b9e6d81597bcf
@@ -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
  }
@@ -14,9 +14,11 @@ module EffectiveMailer
14
14
  mailer_settings.mailer_admin
15
15
  end
16
16
 
17
- def subject_for(action, subject, resource, opts = {})
17
+ def subject_for(action, default, resource, opts = {})
18
18
  mailer_subject = mailer_settings.mailer_subject
19
19
 
20
+ subject = opts[:subject] || opts['subject'] || default
21
+
20
22
  if mailer_subject.respond_to?(:call)
21
23
  subject = self.instance_exec(action, subject, resource, opts, &mailer_subject)
22
24
  end
@@ -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.13.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.13.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