effective_messaging 0.2.2 → 0.3.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/admin/effective_notifications_datatable.rb +4 -0
- data/app/mailers/effective/notifications_mailer.rb +4 -4
- data/app/models/effective/notification.rb +27 -4
- data/app/views/admin/notifications/_form.html.haml +1 -1
- data/app/views/admin/notifications/_form_notification.html.haml +1 -1
- data/app/views/admin/notifications/_notification.html.haml +1 -1
- data/lib/effective_messaging/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: 3aec5e478f15d3fb2fbc704273ebd3b0b9b8c7da1c604f53dca646b9458c7851
|
4
|
+
data.tar.gz: 144b0067e81f347f90fae2b6568b0fe2f138058a809080a68ac67598d2a17ce6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b765eab3df759ffe21ccd8f80d36a8b0f68e233dcfcc8dd79e69a04234a566def85bfaf1b58213af2ee3ca12a12d73da8e4a6d015ef192a4722ef602c6364f4a
|
7
|
+
data.tar.gz: 9b509ff5f1efa7497479fab6910985da6c4a9441529839a16ce887e354191123470e5d9579fa6183c05ee99e34b463325d1dbaf3391137c963d0a4051224962d
|
@@ -6,8 +6,8 @@ module Effective
|
|
6
6
|
raise('expected an Effective::Notification') unless notification.kind_of?(Effective::Notification)
|
7
7
|
|
8
8
|
# Returns a Hash of params to pass to mail()
|
9
|
-
# Includes a :to, :from, etc
|
10
|
-
rendered = notification.render_email
|
9
|
+
# Includes a :to, :from, :subject and :body, etc
|
10
|
+
rendered = notification.assign_renderer(view_context).render_email
|
11
11
|
|
12
12
|
# Attach report
|
13
13
|
attach_report!(notification)
|
@@ -31,8 +31,8 @@ module Effective
|
|
31
31
|
raise('expected an acts_as_reportable resource') unless resource.class.try(:acts_as_reportable?)
|
32
32
|
|
33
33
|
# Returns a Hash of params to pass to mail()
|
34
|
-
# Includes a :to, :from,
|
35
|
-
rendered = notification.render_email(resource)
|
34
|
+
# Includes a :to, :from, :subject and :body
|
35
|
+
rendered = notification.assign_renderer(view_context).render_email(resource)
|
36
36
|
|
37
37
|
# Works with effective_logging to associate this email with the notification
|
38
38
|
headers = headers_for(notification, opts)
|
@@ -6,6 +6,7 @@ module Effective
|
|
6
6
|
|
7
7
|
attr_accessor :current_user
|
8
8
|
attr_accessor :current_resource
|
9
|
+
attr_accessor :view_context
|
9
10
|
|
10
11
|
log_changes if respond_to?(:log_changes)
|
11
12
|
|
@@ -192,7 +193,17 @@ module Effective
|
|
192
193
|
end
|
193
194
|
|
194
195
|
def report_variables
|
195
|
-
|
196
|
+
assigns_for().keys
|
197
|
+
end
|
198
|
+
|
199
|
+
def assign_renderer(view_context)
|
200
|
+
raise('expected renderer to respond to') unless view_context.respond_to?(:root_url)
|
201
|
+
assign_attributes(view_context: view_context)
|
202
|
+
self
|
203
|
+
end
|
204
|
+
|
205
|
+
def renderer
|
206
|
+
view_context || ApplicationController.renderer
|
196
207
|
end
|
197
208
|
|
198
209
|
def rows_count
|
@@ -316,13 +327,25 @@ module Effective
|
|
316
327
|
}.compact
|
317
328
|
end
|
318
329
|
|
319
|
-
|
320
|
-
|
330
|
+
# We pull the Assigns from 3 places:
|
331
|
+
# 1. The report.report_columns
|
332
|
+
# 2. The class's def reportable_view_assigns(view) method
|
333
|
+
def assigns_for(resource = nil)
|
334
|
+
return {} unless report.present?
|
321
335
|
|
322
|
-
|
336
|
+
resource ||= report.reportable.new
|
337
|
+
raise('expected an acts_as_reportable resource') unless resource.class.try(:acts_as_reportable?)
|
338
|
+
|
339
|
+
report_assigns = Array(report.report_columns).inject({}) do |h, column|
|
323
340
|
value = resource.send(column.name)
|
324
341
|
h[column.name] = column.format(value); h
|
325
342
|
end
|
343
|
+
|
344
|
+
reportable_view_assigns = resource.reportable_view_assigns(renderer).deep_stringify_keys
|
345
|
+
raise('expected notification assigns to return a Hash') unless reportable_view_assigns.kind_of?(Hash)
|
346
|
+
|
347
|
+
# Merge all 3
|
348
|
+
report_assigns.merge(reportable_view_assigns)
|
326
349
|
end
|
327
350
|
|
328
351
|
def build_notification_log(resource: nil)
|
@@ -3,7 +3,7 @@
|
|
3
3
|
= render 'admin/notifications/form_notification', notification: notification
|
4
4
|
|
5
5
|
- if notification.persisted? && notification.respond_to?(:logs_datatable)
|
6
|
-
= tab '
|
6
|
+
= tab 'Email Logs' do
|
7
7
|
- datatable = Admin::EffectiveNotificationLogsDatatable.new(notification: notification)
|
8
8
|
= render_inline_datatable(datatable)
|
9
9
|
|
@@ -13,7 +13,7 @@
|
|
13
13
|
|
14
14
|
= card('Preview of Notification') do
|
15
15
|
- resource = notification.report.collection.order('RANDOM()').first
|
16
|
-
- rendered = notification.render_email(resource)
|
16
|
+
- rendered = notification.assign_renderer(self).render_email(resource)
|
17
17
|
|
18
18
|
%table.table
|
19
19
|
%tbody
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_messaging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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-08-
|
11
|
+
date: 2023-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|