effective_reports 0.4.4 → 0.4.6

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: 785afdfa4fc380b5a195e473f9305b55ca373c8d32e45753b2016c6cf75841e8
4
- data.tar.gz: 260cc022bee2520239ace914ab140bbb19eb1812a9aaa5a22a8e52d513513efb
3
+ metadata.gz: 6d17b2b5fa09430885fdf6cbb66abfd0e082189ad50a23b2a4787d4db6d6a9a3
4
+ data.tar.gz: f5b5d85079e66a31df655e261723c20f186afbb5e5959d85cc19460e8a24714e
5
5
  SHA512:
6
- metadata.gz: 41e88a353a63cf6b453db60528cf3dae20c5dd6eb217b58d352bfd248b9ed3491f1b7a0565c8429d6db5c590b015fe70be12e045c4633ab78bcbefa501e69809
7
- data.tar.gz: 38cfca7da087b2b1c52f5be58c8d4acb97493a2c8abafac1ae4eccc3f416a6898d68d657a8b7f68267d74479576777c97a3bba07961a371b15db8e4039b93514
6
+ metadata.gz: 0e415977ddf36b30114f8bf9c2646fb8c71fa6b8e735208e94baf7b76ff58374f5a46dfb7bb1e7ad6833f3947afe938ac7e5c0a69efd12b058f17c0b7c590c61
7
+ data.tar.gz: e80d08319c8f0f99afe66da49f73c2943beec2f573ff9475724c17ff8b42eaff909cf798a6efbc163bbfede1f215bd1aab4ec8635dc94b806a89a8fe001fd19e
@@ -0,0 +1,5 @@
1
+ .col-current_rows_count { width: 150px; }
2
+ .col-notifications { width: 50%; }
3
+ td.col-notifications { padding-left: 1.5rem; }
4
+ .col-notifications > .col-resource_item { display: list-item; list-style-type: disc; }
5
+
@@ -2,14 +2,16 @@ module Admin
2
2
  class EffectiveReportsDatatable < Effective::Datatable
3
3
 
4
4
  datatable do
5
- order :id
5
+ order :updated_at
6
+
6
7
  col :id, visible: false
7
8
 
9
+ col :updated_at, visible: false
8
10
  col :created_at, visible: false
9
11
  col :created_by, visible: false
10
12
 
11
13
  col :title
12
- col :description
14
+ col :description, visible: false
13
15
 
14
16
  col :reportable_class_name, label: 'Resource', search: EffectiveReports.reportable_classes.map(&:to_s), visible: false
15
17
 
@@ -20,7 +22,7 @@ module Admin
20
22
  col :notifications, label: 'Notifications'
21
23
  end
22
24
 
23
- col(:current_rows_count) do |report|
25
+ col :current_rows_count, label: 'Count' do |report|
24
26
  report.collection().count
25
27
  end
26
28
 
@@ -116,6 +116,43 @@ module Effective
116
116
  scopes
117
117
  end
118
118
 
119
+ # Return a string you can copy and paste into a seeds file
120
+ def seeds
121
+ seeds = [
122
+ "report = Effective::Report.where(title: \"#{title}\", reportable_class_name: \"#{reportable_class_name}\").first_or_initialize",
123
+ ("report.assign_attributes(description: \"#{description}\")" if description.present?),
124
+ ].compact
125
+
126
+ seeds += report_columns.map do |column|
127
+ attributes = column.dup.attributes.except('name', 'report_id', 'position', 'as').compact
128
+ attributes.delete('filter') unless attributes['filter']
129
+
130
+ if attributes.present?
131
+ attributes = attributes.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')
132
+ "report.col(:#{column.name}, #{attributes})"
133
+ else
134
+ "report.col(:#{column.name})"
135
+ end
136
+ end
137
+
138
+ seeds += report_scopes.map do |scope|
139
+ attributes = scope.dup.attributes.except('name', 'report_id', 'position').compact
140
+
141
+ if attributes.present?
142
+ attributes = attributes.map { |k, v| "#{k}: #{v.inspect}" }.join(', ')
143
+ "report.scope(:#{scope.name}, #{attributes})"
144
+ else
145
+ "report.scope(:#{scope.name})"
146
+ end
147
+ end
148
+
149
+ seeds += [
150
+ "report.save!"
151
+ ]
152
+
153
+ seeds.join("\n")
154
+ end
155
+
119
156
  def duplicate
120
157
  Effective::Report.new(attributes.except('id', 'updated_at', 'created_at')).tap do |report|
121
158
  report.title = title + ' (Copy)'
@@ -14,6 +14,10 @@
14
14
  = collapse('Show SQL') do
15
15
  %p= report.collection.to_sql
16
16
 
17
+ = collapse('Show Seeds') do
18
+ %small
19
+ %pre= report.seeds
20
+
17
21
  - if (notifications = report.try(:notifications)).present?
18
22
  %p.mt-3
19
23
  The following notifications are sent based on this report:
@@ -1,3 +1,3 @@
1
1
  module EffectiveReports
2
- VERSION = '0.4.4'.freeze
2
+ VERSION = '0.4.6'.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.4.4
4
+ version: 0.4.6
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: 2024-02-20 00:00:00.000000000 Z
11
+ date: 2024-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails