effective_resources 2.22.2 → 2.23.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: 155b88e4f6e0f28971593f6c25da4f9c787a0da62ef6f7f851cec0496def856e
4
- data.tar.gz: 1ad5f683874982e47be3186363354adf0460bfb4af7ed4c4c2e922341a34de66
3
+ metadata.gz: b5203021d6f8cd741603bcf0459f4277f6227c56fde16fd21fb99cae45564667
4
+ data.tar.gz: 505149510d60183e7b0935a043f6be30d96dbb79099225a89c6fdc136ad1100d
5
5
  SHA512:
6
- metadata.gz: 3dca56a7285c363e1bdbb79f775c53d3e645788ecf783caaa72ade6824b191998824548069b6b52ab6d1d78b37828ce5a730c51d92a74810f80cfd1cae44f668
7
- data.tar.gz: baa235bfd2a657daae89b7ae1e5103f10ae9c41e47c4d2fd3e1d18160f7f9eb399d494c614927fa089991209830c50c2c85573c83be0e81751ce4c78d23f9ff3
6
+ metadata.gz: 5efcc14c75d711551ae84574fd1bb64970273a170c7135a645af656b55be45ea8b71520827950933b13d636a32c51c5b0a4a58326666bbcf8722394ae086b6ad
7
+ data.tar.gz: ca89163745a47fe5be4342149df505800565cf6afc6991a9d765de4099d8b2efe17f570f27026eadaa5f7c6629edcd6d7f25c4f0ba5e6a13ea6b840f52c49f15
@@ -20,12 +20,20 @@ module EffectiveActsAsEmailFormHelper
20
20
  # These defaults are only used when there is no email_template
21
21
  email_defaults = form.object.email_form_defaults(action) unless email_template.present?
22
22
 
23
+ from = email_template&.from || email_defaults[:from] || EffectiveResources.mailer_froms.first
24
+ subject = email_template&.subject || email_defaults[:subject] || ''
25
+ body = email_template&.body || email_defaults[:body] || ''
26
+ content_type = email_template&.content_type || email_defaults[:content_type] || ''
27
+
23
28
  locals = {
24
29
  form: form,
25
30
  email_to: to,
31
+ email_from: from,
32
+ email_subject: subject,
33
+ email_body: body,
34
+ email_content_type: content_type,
26
35
  email_skip: skip,
27
36
  email_action: (action || true),
28
- email_defaults: email_defaults,
29
37
  email_template: email_template,
30
38
  email_variables: variables
31
39
  }
@@ -41,7 +41,7 @@ module ActsAsEmailForm
41
41
  validates :email_form_body, presence: true
42
42
 
43
43
  validate(unless: -> { email_form_from.blank? }) do
44
- self.errors.add(:email_form_from, 'must be a valid email address') unless email_form_from.include?('@')
44
+ errors.add(:email_form_from, 'must be a valid email address') unless email_form_from.include?('@')
45
45
  end
46
46
  end
47
47
 
@@ -60,7 +60,7 @@ module ActsAsEmailForm
60
60
 
61
61
  # Only considered when not using an effective email template
62
62
  def email_form_defaults(action)
63
- { from: nil, subject: nil, body: nil }
63
+ { from: nil, subject: nil, body: nil, content_type: 'text/plain' }
64
64
  end
65
65
 
66
66
  end
@@ -4,26 +4,18 @@
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
+ - errors = form.object.errors.present?
8
+
7
9
  - if email_to.present?
8
10
  = form.static_field :email_form_to, label: 'To', value: (email_to.try(:email) || email_to)
9
11
 
10
- - if form.object.errors.present?
11
- = form.select :email_form_from, mailer_froms_collection(), 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
- - from_value = email_template.from || EffectiveResources.mailer_froms.first
18
- = form.select :email_form_from, mailer_froms_collection(), label: 'From', value: from_value
19
- = form.text_field :email_form_subject, label: 'Subject', value: email_template.subject
20
- = form.text_area :email_form_body, label: 'Body', value: email_template.body, rows: 10
12
+ = form.select :email_form_from, mailer_froms_collection(), label: 'From', value: (email_from unless errors)
13
+ = form.text_field :email_form_subject, label: 'Subject', value: (email_subject unless errors)
21
14
 
15
+ - if email_content_type == 'text/html'
16
+ = form.article_editor :email_form_body, label: 'Body', mode: :email, value: (email_body unless errors)
22
17
  - else
23
- - from_value = email_defaults[:from] || EffectiveResources.mailer_froms.first
24
- = form.select :email_form_from, mailer_froms_collection(), label: 'From', value: from_value
25
- = form.text_field :email_form_subject, label: 'Subject', value: (email_defaults[:subject] || '')
26
- = form.text_area :email_form_body, label: 'Body', rows: 10, value: (email_defaults[:body] || '')
18
+ = form.text_area :email_form_body, label: 'Body', rows: 10, value: (email_body unless errors)
27
19
 
28
20
  - if email_variables.present?
29
21
  %p The available variables are:
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '2.22.2'.freeze
2
+ VERSION = '2.23.0'.freeze
3
3
  end
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.22.2
4
+ version: 2.23.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: 2024-06-17 00:00:00.000000000 Z
11
+ date: 2024-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails