effective_email_templates 1.0.3 → 1.0.4

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: d25efc5fcbfdd39c8db6714777574361d0658757e68cfee0e88c075c0b84faa4
4
- data.tar.gz: fc54755485ddc9a80b081ea1448ce4b2ecbccdb546c1b08146dbc36982499100
3
+ metadata.gz: 0a238b8b71692835a5696b2e39af036262811cf4afbbf33c44fdbaf1f97281d7
4
+ data.tar.gz: 943bb0895bc01b14eaa6186f560c3ed7d69ff9a825abbe0e4b287100d5865d40
5
5
  SHA512:
6
- metadata.gz: 6727c12728c12a03a74c9b126b0a16a3c2bf12b16e2dcb8efc53c66b3f9efef9a0f71df34c4a97bf3336b6e1586e606b1ae91e3cbaccfbc833c4c0653c273f51
7
- data.tar.gz: cc09e802861ebbfb5564a6670fb8422c9acf9f522a5230ffdeeb56a0c5e5af7f42d80826335c4ada8cb36649b45a3589e7395228ce45b9541e0d9441d4c70a0a
6
+ metadata.gz: 818eff0c9972b335a6e61eb0afd4bb7abdcf25fbb970d8f3e151be81b102303ae007d88ddb81f9c24b3a28a0055cb22f7c33af7edcd9bb4167ce1bf79e15a7e5
7
+ data.tar.gz: 691d13d33273802ab710493d8509efe3952bf57032a45efd5e2afaedb5d21b81713224c07c09e0dcf1a2b8ed2bf91e5965593520ae9cce3ff2ff35b1b42f44cb
@@ -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 ||= begin
6
+ unless email_review&.template_name == template_name.to_s
7
7
  email_template = Effective::EmailTemplate.where(template_name: template_name).first!
8
- form.object.build_email_review(email_template: email_template)
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
@@ -1,2 +1,13 @@
1
1
  = form.fields_for(:email_review, email_review) do |f|
2
+ = f.text_field :template_name
2
3
  = f.text_area :body, 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
+
@@ -1,3 +1,3 @@
1
1
  module EffectiveEmailTemplates
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_email_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect