effective_email_templates 1.0.3 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/email_templates_controller.rb +5 -1
- data/app/helpers/effective_email_templates_helper.rb +2 -2
- data/app/models/concerns/has_one_email_review.rb +1 -1
- data/app/models/effective/email_review.rb +6 -0
- data/app/models/effective/email_template.rb +6 -4
- data/app/views/effective/email_reviews/_fields.html.haml +12 -1
- data/lib/effective_email_templates/engine.rb +1 -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: c84d011bfae37921bb40271777c47e7a3d2160152c0b408ab7dd76df71eea2e7
|
4
|
+
data.tar.gz: 9a4e13582f66232d044cf19eb5691f654313946b4a8eaa0b489b9d71b2cd9997
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8a0b4e52f4746b5e5a1d174133350838eed9e3ae2e6198400defcede6d4aad45fac66563c19cf4c9c32190f3e9226fe8df69af654029be9061037f1cf78750d
|
7
|
+
data.tar.gz: 30bed477a7ff6817bbe9b2a4887b69fca67b5bc4578de17951d336b4c3c1e50a2bcb87610d9ecef696f38b093ce16cedc6b877d4facd8dfe0ee59b7649c472c9
|
@@ -34,7 +34,11 @@ module Admin
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def edit
|
37
|
-
@email_template =
|
37
|
+
@email_template =
|
38
|
+
Effective::EmailTemplate.where(id: params[:id]).or(
|
39
|
+
Effective::EmailTemplate.where(template_name: params[:id])
|
40
|
+
).first!
|
41
|
+
|
38
42
|
@page_title = 'Edit Email Template'
|
39
43
|
|
40
44
|
authorize_effective_email_templates!
|
@@ -3,9 +3,9 @@ module EffectiveEmailTemplatesHelper
|
|
3
3
|
def effective_email_review_fields(form, template_name)
|
4
4
|
email_review = form.object.email_review
|
5
5
|
|
6
|
-
email_review
|
6
|
+
unless email_review&.template_name == template_name.to_s
|
7
7
|
email_template = Effective::EmailTemplate.where(template_name: template_name).first!
|
8
|
-
|
8
|
+
email_review = Effective::EmailReview.build(email_template: email_template)
|
9
9
|
end
|
10
10
|
|
11
11
|
render(partial: 'effective/email_reviews/fields', locals: { email_review: email_review, form: form })
|
@@ -3,11 +3,13 @@ module Effective
|
|
3
3
|
include ActiveModel::Model
|
4
4
|
|
5
5
|
attr_accessor :email_template
|
6
|
+
attr_accessor :template_name
|
6
7
|
attr_accessor :body
|
7
8
|
|
8
9
|
def self.build(attributes = {})
|
9
10
|
new(attributes).tap do |email_review|
|
10
11
|
email_review.body ||= email_review.email_template&.body
|
12
|
+
email_review.template_name ||= email_review.email_template&.template_name
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
@@ -21,5 +23,9 @@ module Effective
|
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
26
|
+
def email_template
|
27
|
+
@email_template ||= Effective::EmailTemplate.where(template_name: template_name).first
|
28
|
+
end
|
29
|
+
|
24
30
|
end
|
25
31
|
end
|
@@ -2,6 +2,8 @@ module Effective
|
|
2
2
|
class EmailTemplate < ActiveRecord::Base
|
3
3
|
self.table_name = EffectiveEmailTemplates.email_templates_table_name.to_s
|
4
4
|
|
5
|
+
log_changes if respond_to?(:log_changes)
|
6
|
+
|
5
7
|
CONTENT_TYPES = ['text/plain', 'text/html']
|
6
8
|
|
7
9
|
# Attributes
|
@@ -49,14 +51,14 @@ module Effective
|
|
49
51
|
def render(assigns = {})
|
50
52
|
assigns = deep_stringify_assigns(assigns)
|
51
53
|
|
52
|
-
{
|
54
|
+
result = {
|
53
55
|
from: from,
|
54
|
-
cc: cc.presence
|
55
|
-
bcc: bcc.presence
|
56
|
+
cc: cc.presence,
|
57
|
+
bcc: bcc.presence,
|
56
58
|
content_type: content_type,
|
57
59
|
subject: template_subject.render(assigns),
|
58
60
|
body: template_body.render(assigns)
|
59
|
-
}
|
61
|
+
}.compact
|
60
62
|
end
|
61
63
|
|
62
64
|
def template_variables
|
@@ -1,2 +1,13 @@
|
|
1
1
|
= form.fields_for(:email_review, email_review) do |f|
|
2
|
-
= f.
|
2
|
+
= f.hidden_field :template_name
|
3
|
+
= f.text_area :body, required: true, rows: 10
|
4
|
+
|
5
|
+
= collapse('Show / hide email variables') do
|
6
|
+
%p The available variables are:
|
7
|
+
|
8
|
+
%ul
|
9
|
+
- Array(f.object.email_template&.template_variables).each do |variable|
|
10
|
+
%li {{ #{variable} }}
|
11
|
+
|
12
|
+
%small.text-muted Only a developer can add additional variables
|
13
|
+
|
@@ -10,7 +10,7 @@ module EffectiveEmailTemplates
|
|
10
10
|
# Include has_one_email_review concern and allow any ActiveRecord object to call it
|
11
11
|
initializer 'effective_email_templates.active_record' do |app|
|
12
12
|
ActiveSupport.on_load :active_record do
|
13
|
-
ActiveRecord::Base.extend(HasOneEmailReview::
|
13
|
+
ActiveRecord::Base.extend(HasOneEmailReview::Base)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
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.0.
|
4
|
+
version: 1.0.8
|
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: 2020-
|
11
|
+
date: 2020-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|