effective_email_templates 1.4.0 → 1.5.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 +4 -4
- data/app/datatables/effective_email_templates_datatable.rb +4 -16
- data/app/mailers/concerns/effective_email_templates_mailer.rb +7 -3
- data/app/views/admin/email_templates/_form.html.haml +5 -3
- data/lib/effective_email_templates/importer.rb +8 -1
- data/lib/effective_email_templates/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70659c858db00ba3550202875f36f68c3fdc8f955cc0ec6c9c804d82cc45f809
|
4
|
+
data.tar.gz: bcbc544fa37ab446f1a8bc2ddaa88e6aceb96596018bb1b4fa30ade686fdbd7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1f5c5322dfd9717ccd295e175c1406368398b6afa67454c9b568f80cad139924e4f8d0851c73e786edd1d80f81a08786c9b1ad3107620209b942c5463f8c671
|
7
|
+
data.tar.gz: b7c81a31ec4a001c626e0d586e98fc4f22c37b844f359f01578cc0148b69d6834788c4a16a3f739d4d3cec60f109d4d40eeca592ff551b04e418c8a18429be9c
|
@@ -9,23 +9,11 @@ class EffectiveEmailTemplatesDatatable < Effective::Datatable
|
|
9
9
|
|
10
10
|
col :template_name, label: 'Name'
|
11
11
|
|
12
|
-
col :from
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
col :cc do |email_template|
|
17
|
-
sanitize(email_template.cc)
|
18
|
-
end
|
19
|
-
|
20
|
-
col :bcc do |email_template|
|
21
|
-
sanitize(email_template.bcc)
|
22
|
-
end
|
23
|
-
|
12
|
+
col :from, search: EffectiveEmailTemplates.mailer_froms
|
13
|
+
col :cc
|
14
|
+
col :bcc
|
24
15
|
col :subject
|
25
|
-
|
26
|
-
col :body do |email_template|
|
27
|
-
simple_format(email_template.body)
|
28
|
-
end
|
16
|
+
col :body
|
29
17
|
|
30
18
|
col :content_type, visible: false
|
31
19
|
|
@@ -18,7 +18,7 @@ module EffectiveEmailTemplatesMailer
|
|
18
18
|
email_template.subject = subject if subject.present?
|
19
19
|
|
20
20
|
# Add any _url helpers
|
21
|
-
assigns = route_url_assigns(email_template).merge(assigns)
|
21
|
+
assigns = route_url_assigns(email_template, assigns).merge(assigns)
|
22
22
|
|
23
23
|
# Render from the template, possibly with updated body
|
24
24
|
rendered = email_template.render(assigns)
|
@@ -28,8 +28,12 @@ module EffectiveEmailTemplatesMailer
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def route_url_assigns(email_template)
|
32
|
-
email_template.template_variables
|
31
|
+
def route_url_assigns(email_template, existing)
|
32
|
+
route_variables = email_template.template_variables
|
33
|
+
.select { |name| name.ends_with?('_url') }
|
34
|
+
.reject { |name| existing.key?(name) || existing.key?(name.to_sym) }
|
35
|
+
|
36
|
+
route_variables.inject({}) do |h, name|
|
33
37
|
h[name] = public_send(name) if respond_to?(name); h
|
34
38
|
end
|
35
39
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
- if EffectiveEmailTemplates.select_content_type
|
5
5
|
= f.select :content_type, Effective::EmailTemplate::CONTENT_TYPES
|
6
6
|
|
7
|
-
= f.
|
7
|
+
= f.select :from, EffectiveEmailTemplates.mailer_froms, hint: 'Please contact us to add additional sender addresses.'
|
8
8
|
= f.text_field :cc
|
9
9
|
= f.text_field :bcc
|
10
10
|
|
@@ -19,6 +19,8 @@
|
|
19
19
|
- Array(f.object.template_variables).each do |variable|
|
20
20
|
%li {{ #{variable} }}
|
21
21
|
|
22
|
-
%small.text-muted
|
22
|
+
%small.text-muted Please contact us to add additional variables
|
23
23
|
|
24
|
-
= f.submit
|
24
|
+
= f.submit do
|
25
|
+
= f.save 'Save'
|
26
|
+
= f.save 'Continue'
|
@@ -9,8 +9,9 @@ module EffectiveEmailTemplates
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def execute(overwrite:, paths: nil, quiet: false)
|
12
|
-
return false unless ActiveRecord::Base.connection.table_exists?(EffectiveEmailTemplates.email_templates_table_name)
|
12
|
+
return false unless ActiveRecord::Base.connection.table_exists?(EffectiveEmailTemplates.email_templates_table_name || :email_templates)
|
13
13
|
return false if defined?(Tenant) && Tenant.current.blank?
|
14
|
+
return false if EffectiveEmailTemplates.mailer_froms.blank?
|
14
15
|
|
15
16
|
paths ||= if defined?(Tenant)
|
16
17
|
ActionController::Base.view_paths.reject { |view| view.path.include?('/apps/') }.map(&:path) + Tenant.view_paths.map(&:to_s)
|
@@ -38,6 +39,9 @@ module EffectiveEmailTemplates
|
|
38
39
|
def save(email_template, filepath, quiet:)
|
39
40
|
file = File.new(filepath, 'r')
|
40
41
|
|
42
|
+
froms = EffectiveEmailTemplates.mailer_froms
|
43
|
+
raise('expected an Array of mailer froms') unless froms.kind_of?(Array)
|
44
|
+
|
41
45
|
attributes = begin
|
42
46
|
content = YAML.load(file)
|
43
47
|
content.kind_of?(Hash) ? content : {}
|
@@ -49,7 +53,10 @@ module EffectiveEmailTemplates
|
|
49
53
|
content.gsub(match[1], '').strip if match
|
50
54
|
end
|
51
55
|
|
56
|
+
from = froms.find { |from| from.include?(attributes['from']) } || froms.first
|
57
|
+
|
52
58
|
email_template.assign_attributes(attributes)
|
59
|
+
email_template.assign_attributes(from: from)
|
53
60
|
email_template.assign_attributes(body: body)
|
54
61
|
|
55
62
|
if email_template.save
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_email_templates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.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-
|
11
|
+
date: 2023-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|