effective_email_templates 1.0.5 → 1.0.10
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/controllers/admin/email_templates_controller.rb +5 -1
- data/app/datatables/effective_email_templates_datatable.rb +2 -1
- data/app/helpers/effective_email_templates_helper.rb +9 -1
- data/app/models/concerns/has_one_email_review.rb +1 -1
- data/app/models/effective/email_template.rb +20 -4
- data/app/views/admin/email_templates/_form.html.haml +3 -1
- data/app/views/effective/email_reviews/_fields.html.haml +1 -1
- data/config/effective_email_templates.rb +3 -0
- data/lib/effective_email_templates.rb +1 -0
- data/lib/effective_email_templates/engine.rb +1 -1
- data/lib/effective_email_templates/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ed72c520b24e50d1102d0e89a4e353c399d8b0f6e95e44bb872e7dc75e6805e
|
4
|
+
data.tar.gz: b0cf351fffa4982b8bb9d6e8665cde74bdcefc02c4a551d03d7eaf29ed21b96c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02d5add10f230239034b43148b5c6efc73da5a886ffcaa62cebdb36e34ee3bbaa368f3fd5fb830289fb46952cad7ff9bcc49ccb6610f6a1ad535c615bd784380
|
7
|
+
data.tar.gz: fa8fdfdc3408a0e778ab6510363c77d8d7704cb0dd9cabac69882b28cdc9dea9bcd607ee723421114afdde9e64a3e626a6b53e1103d0d7680c26ba9746290f4a
|
@@ -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!
|
@@ -14,6 +14,8 @@ class EffectiveEmailTemplatesDatatable < Effective::Datatable
|
|
14
14
|
col :subject
|
15
15
|
col :body
|
16
16
|
|
17
|
+
col :content_type, visible: false
|
18
|
+
|
17
19
|
actions_col partial: '/admin/email_templates/actions', partial_as: 'email_template'
|
18
20
|
end
|
19
21
|
|
@@ -21,4 +23,3 @@ class EffectiveEmailTemplatesDatatable < Effective::Datatable
|
|
21
23
|
Effective::EmailTemplate.all
|
22
24
|
end
|
23
25
|
end
|
24
|
-
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module EffectiveEmailTemplatesHelper
|
2
2
|
|
3
|
-
|
3
|
+
# We are given a form to essentially send an email
|
4
|
+
def effective_email_review_fields(form, template_name, mail = nil)
|
5
|
+
raise('expected form.object to respond to email_review') unless form.object.respond_to?(:email_review)
|
6
|
+
|
4
7
|
email_review = form.object.email_review
|
5
8
|
|
6
9
|
unless email_review&.template_name == template_name.to_s
|
@@ -8,6 +11,11 @@ module EffectiveEmailTemplatesHelper
|
|
8
11
|
email_review = Effective::EmailReview.build(email_template: email_template)
|
9
12
|
end
|
10
13
|
|
14
|
+
if mail.present?
|
15
|
+
raise('expected a mail object') unless mail.kind_of?(ActionMailer::MessageDelivery)
|
16
|
+
email_review.body ||= mail.message.body
|
17
|
+
end
|
18
|
+
|
11
19
|
render(partial: 'effective/email_reviews/fields', locals: { email_review: email_review, form: form })
|
12
20
|
end
|
13
21
|
|
@@ -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
|
@@ -42,6 +44,20 @@ module Effective
|
|
42
44
|
validates :content_type, presence: true, inclusion: { in: CONTENT_TYPES }
|
43
45
|
validates :template_name, presence: true
|
44
46
|
|
47
|
+
# validate(if: -> { content_type == 'text/html' && body.present? }) do
|
48
|
+
# unless body.include?('<') && body.include?('>')
|
49
|
+
# self.errors.add(:content_type, 'expected html tags in body')
|
50
|
+
# self.errors.add(:body, 'expected html tags in body')
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
|
54
|
+
# validate(if: -> { content_type == 'text/plain' && body.present? }) do
|
55
|
+
# if body.include?('</a>') || body.include?('</p>')
|
56
|
+
# self.errors.add(:content_type, 'expected no html tags in body')
|
57
|
+
# self.errors.add(:body, 'expected no html tags in body')
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
|
45
61
|
def to_s
|
46
62
|
template_name.presence || 'New Email Template'
|
47
63
|
end
|
@@ -49,14 +65,14 @@ module Effective
|
|
49
65
|
def render(assigns = {})
|
50
66
|
assigns = deep_stringify_assigns(assigns)
|
51
67
|
|
52
|
-
{
|
68
|
+
result = {
|
53
69
|
from: from,
|
54
|
-
cc: cc.presence
|
55
|
-
bcc: bcc.presence
|
70
|
+
cc: cc.presence,
|
71
|
+
bcc: bcc.presence,
|
56
72
|
content_type: content_type,
|
57
73
|
subject: template_subject.render(assigns),
|
58
74
|
body: template_body.render(assigns)
|
59
|
-
}
|
75
|
+
}.compact
|
60
76
|
end
|
61
77
|
|
62
78
|
def template_variables
|
@@ -1,6 +1,8 @@
|
|
1
1
|
= effective_form_with(model: email_template, url: email_template.persisted? ? effective_email_templates.admin_email_template_path(email_template.id) : effective_email_templates.admin_email_templates_path) do |f|
|
2
2
|
= f.static_field :template_name, label: 'Name'
|
3
|
-
|
3
|
+
|
4
|
+
- if EffectiveEmailTemplates.select_content_type
|
5
|
+
= f.select :content_type, Effective::EmailTemplate::CONTENT_TYPES
|
4
6
|
|
5
7
|
= f.email_field :from, hint: 'Whom the email will be sent from'
|
6
8
|
= f.text_field :cc
|
@@ -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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -119,7 +119,7 @@ homepage: https://github.com/code-and-effect/effective_email_templates
|
|
119
119
|
licenses:
|
120
120
|
- MIT
|
121
121
|
metadata: {}
|
122
|
-
post_install_message:
|
122
|
+
post_install_message:
|
123
123
|
rdoc_options: []
|
124
124
|
require_paths:
|
125
125
|
- lib
|
@@ -134,8 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
138
|
-
signing_key:
|
137
|
+
rubygems_version: 3.1.2
|
138
|
+
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Effective Email Templates provides an admin access to modify email templates
|
141
141
|
test_files: []
|