effective_email_templates 1.4.1 → 1.5.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: f6f761daef6975677ea045c02bec4fe35c12613428d7a471ea96090d9ff4f8ee
4
- data.tar.gz: 643bb762e01e5f086d90fe91465dc150033f27e2cd913f3295b02c1d35e0cff0
3
+ metadata.gz: 70659c858db00ba3550202875f36f68c3fdc8f955cc0ec6c9c804d82cc45f809
4
+ data.tar.gz: bcbc544fa37ab446f1a8bc2ddaa88e6aceb96596018bb1b4fa30ade686fdbd7f
5
5
  SHA512:
6
- metadata.gz: d516cd29cdbf67641658d726e3d6ac3c670d25f1a563827516e05f8bb78aeb31c316f3270c4cdf981d74cd5d0efb8f980bb4035b6bdca61738000f4a344b7d20
7
- data.tar.gz: 1e10e8b93b994cbbb3a8b715a97d039648655cd2f307fbbdf5cf3caafae73fd4c735ead6a8461e9e5c209a00ddb5dc4dc9d773919192d92a29d1b5a1d3cfe8d1
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 do |email_template|
13
- sanitize(email_template.from)
14
- end
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
 
@@ -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.text_field :from, hint: 'Whom the email will be sent from'
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 Only a developer can add additional variables
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveEmailTemplates
2
- VERSION = '1.4.1'.freeze
2
+ VERSION = '1.5.0'.freeze
3
3
  end
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.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-09-25 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