effective_reports 0.1.1 → 0.1.3

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: 5c1c05c8943d42999d6cb9bc8f788af7b1efd9490108fc32a31a06d4429d9455
4
- data.tar.gz: 7ad823fb06f1837bbe2d450f10d7d4e4c07064675fa7009847235c2f49b9cdaa
3
+ metadata.gz: 991d7b212a5902f3a50a65e1a9ab6261772f610d5b9c34fd531cd42d8fc8dd21
4
+ data.tar.gz: 880c5838c51e1f53fa71549d578e290f3b09c70388f0351d8d9b47972829afae
5
5
  SHA512:
6
- metadata.gz: 72df2d6b3d8f52aa3c348707b706f22204b22b3c1e1faa766f4fcdd069122fcfd41b0253f3e5d5c275ef2cd9fcced88cb182f1a34ff569b61ea48106ffbdab68
7
- data.tar.gz: 263b2b601838d2eaa0823093264dbd6ce0f16c82572a0dc05e0a63b78edc8b5a0a75dad25ca2ad03924f6ae466387f0efe407f0f14cd0e99e4377bc56d8d0931
6
+ metadata.gz: 35c55dd39bc05eaf96a9308ba9193f9f188fd5248f1c3f31b8398c20cae3fc110bf15156fc8d6696ab4f16a6ba5f9b30d3ccab8c15b1f048805173f9bb90080d
7
+ data.tar.gz: 639050630369e02d01d5fcb7e43019d70f1d96b03e5ccb24dc32cad0ac6b051ba5a20f73d1c8feb3253d6200c3fad47bc98715d18cef9f05237691b0f09efacf
@@ -43,7 +43,7 @@ module EffectiveReportsHelper
43
43
  ['Greater than >', :gt],
44
44
  ['Greater than or equal to >=', :gteq],
45
45
  ['Less than <', :lt],
46
- ['Less than or equal to <', :lteq],
46
+ ['Less than or equal to <=', :lteq],
47
47
  ]
48
48
  when :belongs_to, :belongs_to_polymorphic, :has_many, :has_one
49
49
  [
@@ -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
@@ -37,12 +37,16 @@ module Effective
37
37
  end
38
38
 
39
39
  def to_s
40
- name.presence || 'report scope'
40
+ [name, operation_label, value].compact.join(' ').presence || 'report scope'
41
41
  end
42
42
 
43
43
  def value
44
44
  value_date || value_decimal || value_integer || value_price || value_string.presence || value_boolean
45
45
  end
46
46
 
47
+ def operation_label
48
+ return '=' if advanced?
49
+ end
50
+
47
51
  end
48
52
  end
@@ -177,17 +177,17 @@
177
177
  = frs.hidden_field :advanced, value: true
178
178
 
179
179
  - if type == :boolean
180
- = frs.radios :value_boolean, reportable_boolean_collection, label: 'Value', buttons: true, required: true, label: false
180
+ = frs.radios :value_boolean, reportable_boolean_collection, buttons: true, required: true, label: false
181
181
  - elsif type == :date
182
- = frs.date_field :value_date, label: 'Value', required: true, label: false
182
+ = frs.date_field :value_date, required: true, label: false
183
183
  - elsif type == :decimal
184
- = frs.date_field :value_decimal, label: 'Value', required: true, label: false
184
+ = frs.date_field :value_decimal, required: true, label: false
185
185
  - elsif type == :integer
186
- = frs.integer_field :value_integer, label: 'Value', required: true, label: false
186
+ = frs.integer_field :value_integer, required: true, label: false
187
187
  - elsif type == :price
188
- = frs.price_field :value_price, label: 'Value', required: true, label: false
188
+ = frs.price_field :value_price, required: true, label: false
189
189
  - elsif type == :string
190
- = frs.text_field :value_string, label: 'Value', required: true, label: false
190
+ = frs.text_field :value_string, required: true, label: false
191
191
  - else
192
192
  - raise("Unexpected scope datatype: #{type || 'nil'}")
193
193
 
@@ -1,5 +1,5 @@
1
1
  - if report.description.present?
2
- %p= report.description.to_s
2
+ %p= simple_format(report.description)
3
3
 
4
4
  - if report.filtered_report_columns.present? || report.report_scopes.present?
5
5
  %p The results of this report have been filtered by the following:
@@ -1,3 +1,3 @@
1
1
  module EffectiveReports
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  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.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-04 00:00:00.000000000 Z
11
+ date: 2023-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails