effective_reports 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/report.rb +5 -0
- data/app/models/effective/report_column.rb +20 -0
- data/lib/effective_reports/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: 991d7b212a5902f3a50a65e1a9ab6261772f610d5b9c34fd531cd42d8fc8dd21
|
4
|
+
data.tar.gz: 880c5838c51e1f53fa71549d578e290f3b09c70388f0351d8d9b47972829afae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35c55dd39bc05eaf96a9308ba9193f9f188fd5248f1c3f31b8398c20cae3fc110bf15156fc8d6696ab4f16a6ba5f9b30d3ccab8c15b1f048805173f9bb90080d
|
7
|
+
data.tar.gz: 639050630369e02d01d5fcb7e43019d70f1d96b03e5ccb24dc32cad0ac6b051ba5a20f73d1c8feb3253d6200c3fad47bc98715d18cef9f05237691b0f09efacf
|
@@ -26,6 +26,7 @@ module Effective
|
|
26
26
|
|
27
27
|
scope :deep, -> { includes(:report_columns, :report_scopes) }
|
28
28
|
scope :sorted, -> { order(:title) }
|
29
|
+
scope :emails, -> { where(id: ReportColumn.emails.select(:report_id)) }
|
29
30
|
|
30
31
|
validates :title, presence: true, uniqueness: true
|
31
32
|
validates :reportable_class_name, presence: true
|
@@ -42,6 +43,10 @@ module Effective
|
|
42
43
|
report_columns.select(&:filter?)
|
43
44
|
end
|
44
45
|
|
46
|
+
def email_report_column
|
47
|
+
report_columns.find { |column| column.name.include?('email') }
|
48
|
+
end
|
49
|
+
|
45
50
|
# Used to build the Reports form
|
46
51
|
# { id: :integer, archived: :boolean }
|
47
52
|
def reportable_attributes
|
@@ -27,6 +27,7 @@ module Effective
|
|
27
27
|
|
28
28
|
scope :deep, -> { includes(:report) }
|
29
29
|
scope :sorted, -> { order(:position) }
|
30
|
+
scope :emails, -> { where('name ILIKE ?', "%email%") }
|
30
31
|
|
31
32
|
before_validation(if: -> { report.present? }) do
|
32
33
|
self.position ||= (report.report_columns.map(&:position).compact.max || -1) + 1
|
@@ -57,6 +58,25 @@ module Effective
|
|
57
58
|
[name, operation_label, value].compact.join(' ').presence || 'report column'
|
58
59
|
end
|
59
60
|
|
61
|
+
def format(value)
|
62
|
+
return '' if value.blank?
|
63
|
+
|
64
|
+
case as.to_sym
|
65
|
+
when :boolean then value.to_s
|
66
|
+
when :date then value.strftime('%F')
|
67
|
+
when :decimal then value.to_s
|
68
|
+
when :integer then value.to_s
|
69
|
+
when :price then '$' + ('%0.2f' % (value / 100.0))
|
70
|
+
when :string then value.to_s
|
71
|
+
when :belongs_to then value.to_s
|
72
|
+
when :belongs_to_polymorphic then value.to_s
|
73
|
+
when :has_many then Array(value).map { |value| value.to_s }.join("\n\n")
|
74
|
+
when :has_one then value.to_s
|
75
|
+
else
|
76
|
+
raise("unexpected as: #{as || 'nil'}")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
60
80
|
def as_associated?
|
61
81
|
[:belongs_to, :belongs_to_polymorphic, :has_many, :has_one].include?(as.to_sym)
|
62
82
|
end
|
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.1.
|
4
|
+
version: 0.1.3
|
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-01
|
11
|
+
date: 2023-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|