simple_drilldown 0.8.0 → 0.8.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/views/drilldown/_record_list.html.erb +6 -4
- data/app/views/drilldown/_summary_table.html.erb +13 -11
- data/lib/simple_drilldown/changes.rb +25 -0
- data/lib/simple_drilldown/controller.rb +14 -12
- data/lib/simple_drilldown/helper.rb +2 -2
- data/lib/simple_drilldown/routing.rb +1 -0
- data/lib/simple_drilldown/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb13ecfcc4daffce07a6fc1e9908b0f4630b218c4b8329fb34202f33f9cde216
|
4
|
+
data.tar.gz: c17b1af4432593116544a0d0068441f03d902ee6feff0d7fe27ea36284fb3a09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e83c939a8340e39df0595e76342efcb529bf5dde9b55a9c27af4191df6c4931a895f13f9ab2a70dadb58f61c6580d7c5209008a31874cb581a998aab8344df3
|
7
|
+
data.tar.gz: 61671368c513f84b7d3ac8a2482c062e682acde751cf2b98f82f0718e8f20f9b691296203c21efafc7aec74f738ade973637a6e9cf3fef4eb548586b59acfb31
|
@@ -1,11 +1,13 @@
|
|
1
1
|
<% unless result[:records].empty? %>
|
2
2
|
<tr>
|
3
3
|
<td colspan="<%= controller.c_summary_fields.size + 1 %>">
|
4
|
-
<table class="table table-condensed table-bordered" style="padding-bottom: 10px;">
|
4
|
+
<table id="drilldown-records-<%= result[:value] %>" class="table table-condensed table-bordered" style="padding-bottom: 10px;">
|
5
5
|
<%= render :partial => '/drilldown/row_header' %>
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
<tbody>
|
7
|
+
<% result[:records].each do |t| %>
|
8
|
+
<%= render :partial => '/drilldown/row', :locals => { :transaction => t, :previous_transaction => nil, :errors => [], :error_row => false, :meter1_errors => false } %>
|
9
|
+
<% end %>
|
10
|
+
</tbody>
|
9
11
|
</table>
|
10
12
|
</td>
|
11
13
|
</tr>
|
@@ -1,12 +1,14 @@
|
|
1
|
-
<table class="table table-condensed table-bordered">
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
</
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
<table id="drilldown-summary-table" class="table table-condensed table-bordered">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<% @dimensions.each do |d| %>
|
5
|
+
<th><%= h d[:pretty_name] %></th>
|
6
|
+
<% end %>
|
7
|
+
<th><%= t controller.c_target_class.table_name.capitalize %></th>
|
8
|
+
<%= controller.c_summary_fields.map { |l| "<th>#{t(l)}</th>" }.join("\n").html_safe %>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
<%= summary_row(@result) %>
|
13
|
+
</tbody>
|
12
14
|
</table>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SimpleDrilldown
|
4
|
+
# Allow tracking changes for a field
|
5
|
+
module Changes
|
6
|
+
def self.included(clazz)
|
7
|
+
clazz.extend ClassMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
# Class methods for Changes
|
11
|
+
module ClassMethods
|
12
|
+
def changes_for(*fields)
|
13
|
+
fields.each do |field|
|
14
|
+
condition_proc = lambda do
|
15
|
+
in_join = is_a?(ActiveRecord::Associations::JoinDependency::JoinAssociation)
|
16
|
+
table_alias = in_join ? aliased_table_name : AuditLog.table_name
|
17
|
+
"#{table_alias}.new_values LIKE '%#{field}%'"
|
18
|
+
end
|
19
|
+
has_many :"#{field}_changes", -> { where(condition_proc.call).order(:created_at) },
|
20
|
+
class_name: :AuditLog, foreign_key: :record_id
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -15,7 +15,7 @@ module SimpleDrilldown
|
|
15
15
|
class_attribute :c_default_fields, default: []
|
16
16
|
class_attribute :c_default_select_value, default: SimpleDrilldown::Search::SelectValue::COUNT
|
17
17
|
class_attribute :c_dimension_defs
|
18
|
-
class_attribute :c_fields
|
18
|
+
class_attribute :c_fields, default: []
|
19
19
|
class_attribute :c_list_includes, default: []
|
20
20
|
class_attribute :c_list_order
|
21
21
|
class_attribute :c_select, default: 'count(*) as count'
|
@@ -153,14 +153,15 @@ module SimpleDrilldown
|
|
153
153
|
end
|
154
154
|
includes.uniq!
|
155
155
|
end
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
156
|
+
rows_query = c_target_class.unscoped.where(c_base_condition)
|
157
|
+
.select("#{query[:select]} AS value")
|
158
|
+
.joins(make_join([], c_target_class.name.underscore.to_sym, includes))
|
159
|
+
.order('value')
|
160
|
+
.group(:value)
|
161
|
+
# rows_query = rows_query.without_deleted if c_target_class.try :paranoid?
|
162
|
+
rows_query = rows_query.where(filter_conditions) if filter_conditions
|
163
|
+
rows_query = rows_query.where(query[:where]) if query[:where]
|
164
|
+
rows = rows_query.to_a
|
164
165
|
filter_fields = search.filter[field.to_s]
|
165
166
|
filter_fields&.each do |selected_value|
|
166
167
|
next if rows.find { |r| r[:value].to_s == selected_value }
|
@@ -274,7 +275,8 @@ module SimpleDrilldown
|
|
274
275
|
ass_order_prefixed.gsub!(/\b#{cname}\b/, "#{include_alias}.#{cname}")
|
275
276
|
end
|
276
277
|
paranoid_clause = 'AND t2.deleted_at IS NULL' if ass.klass.paranoid?
|
277
|
-
# FIXME(uwe): Should we add "where" from the ScopeHolder here as well?
|
278
|
+
# FIXME(uwe): Should we add "where" from the ScopeHolder here as well?
|
279
|
+
# Ref: SimpleDrilldown::Changes#changes_for
|
278
280
|
min_query = <<~SQL
|
279
281
|
SELECT MIN(#{ass_order}) FROM #{include_table} t2 WHERE t2.#{fk_col} = #{model_table}.id #{paranoid_clause}
|
280
282
|
SQL
|
@@ -347,8 +349,8 @@ module SimpleDrilldown
|
|
347
349
|
rows = c_target_class.unscoped.where(c_base_condition).select(select).where(conditions)
|
348
350
|
.joins(joins)
|
349
351
|
.group(group)
|
350
|
-
.order(order)
|
351
|
-
|
352
|
+
.order(order)
|
353
|
+
.to_a
|
352
354
|
if rows.empty?
|
353
355
|
@result = { value: 'All', count: 0, row_count: 0, nodes: 0, rows: [] }
|
354
356
|
c_summary_fields.each { |f| @result[f] = 0 }
|
@@ -38,7 +38,7 @@ module SimpleDrilldown
|
|
38
38
|
html << summary_row(r, result, dimension + 1, sub_headers, i.positive?)
|
39
39
|
end
|
40
40
|
elsif @search.list
|
41
|
-
html << render(partial: '/drilldown/record_list', locals: { result: result })
|
41
|
+
html << render(partial: '/drilldown/record_list', locals: { result: result, dimension: dimension })
|
42
42
|
end
|
43
43
|
if dimension < @dimensions.size
|
44
44
|
html << render(partial: '/drilldown/summary_total_row',
|
@@ -89,7 +89,7 @@ module SimpleDrilldown
|
|
89
89
|
private
|
90
90
|
|
91
91
|
def caption_txt
|
92
|
-
"#{controller.c_target_class} #{t(@search.select_value.downcase)}" +
|
92
|
+
"#{controller.c_target_class} #{I18n.t(@search.select_value.downcase)}" +
|
93
93
|
(@dimensions && @dimensions.any? ? " by #{@dimensions.map { |d| d[:pretty_name] }.join(' and ')}" : '')
|
94
94
|
end
|
95
95
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_drilldown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uwe Kubosch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caxlsx_rails
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/generators/drilldown_controller/templates/drilldown_controller.rb.erb
|
143
143
|
- lib/generators/drilldown_controller/templates/drilldown_controller_test.rb.erb
|
144
144
|
- lib/simple_drilldown.rb
|
145
|
+
- lib/simple_drilldown/changes.rb
|
145
146
|
- lib/simple_drilldown/controller.rb
|
146
147
|
- lib/simple_drilldown/engine.rb
|
147
148
|
- lib/simple_drilldown/helper.rb
|