effective_reports 0.3.0 → 0.4.1
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/mailers/effective/reports_mailer.rb +1 -1
- data/app/models/concerns/acts_as_reportable.rb +7 -2
- data/app/models/effective/report.rb +11 -1
- data/app/models/effective/report_scope.rb +16 -2
- data/app/views/admin/reports/_report.html.haml +18 -17
- data/config/effective_reports.rb +1 -3
- data/lib/effective_reports/version.rb +1 -1
- data/lib/effective_reports.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: 70923b082133448581e40494e8a68f93c231a8441fd7bbeda0281554ffe9f78b
|
4
|
+
data.tar.gz: 554d4e33b48736d92dbfed175a3aea01009f7fed5eda4c5f7bfcba8fe5c2c46e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 122a4720d2e2c3e883a53138ac7bcf954885b85d27ac486f92ee887471e9ae50be45a28e2bb1118cf57cffdd125557d499c09a1d4a4ff456bc7049f4c15f5659
|
7
|
+
data.tar.gz: da2fce3831d715481f6180e9a73882fd79ca3604ff061269a5542316669038f43cffcac4bbf8d41e124d8ac7de5304c118d9af070ae37edadd145dfd944c3b7d
|
@@ -2,7 +2,7 @@ module Effective
|
|
2
2
|
class ReportsMailer < EffectiveReports.parent_mailer_class
|
3
3
|
|
4
4
|
include EffectiveMailer
|
5
|
-
include EffectiveEmailTemplatesMailer
|
5
|
+
#include EffectiveEmailTemplatesMailer
|
6
6
|
|
7
7
|
# def reports_submitted(resource, opts = {})
|
8
8
|
# @assigns = assigns_for(resource)
|
@@ -6,6 +6,7 @@ module ActsAsReportable
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
PRICE_NAME_ATTRIBUTES = ['price', 'subtotal', 'tax', 'total', 'current_revenue', 'current_revenue_subtotal', 'current_revenue_tax', 'deferred_revenue', 'deferred_revenue_subtotal', 'deferred_revenue_tax', 'amount_owing', 'surcharge']
|
9
|
+
DENY_LIST = [:logged_changes, :password, :encrypted_password]
|
9
10
|
|
10
11
|
module Base
|
11
12
|
def acts_as_reportable(options = nil)
|
@@ -35,7 +36,11 @@ module ActsAsReportable
|
|
35
36
|
end
|
36
37
|
|
37
38
|
# Used for the notifications mailer
|
38
|
-
|
39
|
+
# This should be a view_context that you can call urls on
|
40
|
+
# But it's a bit weird and sometimes it's just nil (like on an update action in the validation)
|
41
|
+
# Be careful when you code stuff for it
|
42
|
+
# Always return all the keys, and leave the value blank if view is blank
|
43
|
+
def reportable_view_assigns(view = nil)
|
39
44
|
{}
|
40
45
|
end
|
41
46
|
|
@@ -76,7 +81,7 @@ module ActsAsReportable
|
|
76
81
|
end; h
|
77
82
|
end
|
78
83
|
|
79
|
-
atts.merge(associated)
|
84
|
+
atts.merge(associated).except(*DENY_LIST)
|
80
85
|
end
|
81
86
|
|
82
87
|
end
|
@@ -36,6 +36,16 @@ module Effective
|
|
36
36
|
validates :title, presence: true, uniqueness: true
|
37
37
|
validates :reportable_class_name, presence: true
|
38
38
|
|
39
|
+
validate do
|
40
|
+
error = begin
|
41
|
+
collection().to_sql; nil
|
42
|
+
rescue StandardError => e
|
43
|
+
e.message
|
44
|
+
end
|
45
|
+
|
46
|
+
errors.add(:base, "Invalid Report: #{error}") if error.present?
|
47
|
+
end
|
48
|
+
|
39
49
|
def to_s
|
40
50
|
title.presence || 'report'
|
41
51
|
end
|
@@ -107,7 +117,7 @@ module Effective
|
|
107
117
|
|
108
118
|
# Apply Scopes
|
109
119
|
report_scopes.each do |scope|
|
110
|
-
collection =
|
120
|
+
collection = scope.apply_scope(collection)
|
111
121
|
end
|
112
122
|
|
113
123
|
# Apply Includes
|
@@ -37,9 +37,19 @@ module Effective
|
|
37
37
|
end
|
38
38
|
|
39
39
|
validate(if: -> {report&.reportable }) do
|
40
|
-
|
41
|
-
|
40
|
+
reportable = report.reportable
|
41
|
+
|
42
|
+
if reportable.new.reportable_scopes.key?(name.to_sym) == false
|
43
|
+
errors.add(:name, "acts_as_reportable #{reportable} reportable_scopes() missing :#{name} scope")
|
44
|
+
end
|
45
|
+
|
46
|
+
scope_error = begin
|
47
|
+
apply_scope(reportable.all).to_sql; nil
|
48
|
+
rescue StandardError => e
|
49
|
+
e.message
|
42
50
|
end
|
51
|
+
|
52
|
+
self.errors.add(:name, scope_error) if scope_error.present?
|
43
53
|
end
|
44
54
|
|
45
55
|
def to_s
|
@@ -54,5 +64,9 @@ module Effective
|
|
54
64
|
return '=' if advanced?
|
55
65
|
end
|
56
66
|
|
67
|
+
def apply_scope(collection)
|
68
|
+
value.nil? ? collection.send(name) : collection.send(name, value)
|
69
|
+
end
|
70
|
+
|
57
71
|
end
|
58
72
|
end
|
@@ -1,23 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
= card do
|
2
|
+
- if report.description.present?
|
3
|
+
%p= simple_format(report.description)
|
3
4
|
|
4
|
-
- if report.filtered_report_columns.present? || report.report_scopes.present?
|
5
|
-
|
5
|
+
- if report.filtered_report_columns.present? || report.report_scopes.present?
|
6
|
+
%p The results of this report have been filtered by the following:
|
6
7
|
|
7
|
-
- if report.filtered_report_columns.present?
|
8
|
-
|
8
|
+
- if report.filtered_report_columns.present?
|
9
|
+
%p= badges(report.filtered_report_columns.map(&:to_s))
|
9
10
|
|
10
|
-
- if report.report_scopes.present?
|
11
|
-
|
11
|
+
- if report.report_scopes.present?
|
12
|
+
%p= badges(report.report_scopes.map(&:to_s))
|
12
13
|
|
13
|
-
= collapse('Show SQL') do
|
14
|
-
|
14
|
+
= collapse('Show SQL') do
|
15
|
+
%p= report.collection.to_sql
|
15
16
|
|
16
|
-
- if (notifications = report.try(:notifications)).present?
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
- if (notifications = report.try(:notifications)).present?
|
18
|
+
%p.mt-3
|
19
|
+
The following notifications are sent based on this report:
|
20
|
+
- notifications.each do |notification|
|
21
|
+
= link_to(notification, effective_messaging.edit_admin_notification_path(notification), target: '_blank')
|
21
22
|
|
22
|
-
- datatable = EffectiveReportDatatable.new(report: report)
|
23
|
-
= render_datatable(datatable)
|
23
|
+
- datatable = EffectiveReportDatatable.new(report: report)
|
24
|
+
= render_datatable(datatable)
|
data/config/effective_reports.rb
CHANGED
@@ -25,9 +25,7 @@ EffectiveReports.setup do |config|
|
|
25
25
|
# config.deliver_method = nil # The deliver method, deliver_later or deliver_now
|
26
26
|
# config.mailer_layout = nil # Default mailer layout
|
27
27
|
# config.mailer_sender = nil # Default From value
|
28
|
+
# config.mailer_froms = nil # Default Froms collection
|
28
29
|
# config.mailer_admin = nil # Default To value for Admin correspondence
|
29
30
|
# config.mailer_subject = nil # Proc.new method used to customize Subject
|
30
|
-
|
31
|
-
# Will work with effective_email_templates gem
|
32
|
-
config.use_effective_email_templates = true
|
33
31
|
end
|
data/lib/effective_reports.rb
CHANGED
@@ -14,7 +14,7 @@ module EffectiveReports
|
|
14
14
|
|
15
15
|
# Effective Gem
|
16
16
|
:layout,
|
17
|
-
:mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :
|
17
|
+
:mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_froms, :mailer_admin, :mailer_subject
|
18
18
|
]
|
19
19
|
end
|
20
20
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_reports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
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-
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|