simple_drilldown 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/simple_drilldown/application.css +0 -1
- data/app/views/drilldown/_chart.html.erb +19 -3
- data/app/views/drilldown/_summary_row.html.erb +9 -0
- data/app/views/drilldown/_summary_table.html.erb +1 -1
- data/lib/generators/drilldown_controller/templates/drilldown_controller.rb.erb +9 -0
- data/lib/simple_drilldown/controller.rb +2 -11
- data/lib/simple_drilldown/search.rb +2 -4
- data/lib/simple_drilldown/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: 48e5faf8ea7325353ae1283ed36863a2721ba4110c883be528314b7c868af356
|
4
|
+
data.tar.gz: aaa55b27d81bef734bb52c897eff6c437c05832400fbc29bbed219ccf02e0ea3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a711048cd982171d465dfffc99e6155f3d22d0ca2d2c6cdb55f2be590aa76994036135e186bd7b1a5f594f9986799618208d42bd25b6e2f71452878f117e2a46
|
7
|
+
data.tar.gz: dbb15e5f741988a2b09f1cb27005d0bece4930572e24e96773752f6648608e5e88a648e0572fb3370713f5756789b543a4962f1b9320646e713cc11a9f66c71d
|
@@ -2,14 +2,14 @@
|
|
2
2
|
data =
|
3
3
|
case @dimensions.size
|
4
4
|
when 0
|
5
|
-
{ @result[:value] => @result[
|
5
|
+
{ @result[:value] => @result[@search.select_value] }
|
6
6
|
when 1
|
7
|
-
@result[:rows].map { |r| [@dimensions[0][:label_method] ? @dimensions[0][:label_method].call(r[:value]) : r[:value], r[
|
7
|
+
@result[:rows].map { |r| [@dimensions[0][:label_method] ? @dimensions[0][:label_method].call(r[:value]) : r[:value], r[@search.select_value]] }
|
8
8
|
when 2
|
9
9
|
@result[:rows].map do |r|
|
10
10
|
{
|
11
11
|
name: r[:value],
|
12
|
-
data: r[:rows].map { |r2| [r2[:value], r2[
|
12
|
+
data: r[:rows].map { |r2| [r2[:value], r2[@search.select_value]] }
|
13
13
|
}
|
14
14
|
end
|
15
15
|
when 3
|
@@ -56,6 +56,22 @@
|
|
56
56
|
<%= form.radio_button 'display_type', SimpleDrilldown::Search::DisplayType::NONE, { :onChange => 'form.submit()' } %>
|
57
57
|
<%= form.label :display_type_none, t(:none) %>
|
58
58
|
|
59
|
+
<% if controller.c_summary_fields.present? && @search.display_type != SimpleDrilldown::Search::DisplayType::NONE %>
|
60
|
+
<div class="text-center">
|
61
|
+
<label style="margin-bottom:0;margin-right:1em" for="search_select_value">Value: </label>
|
62
|
+
<div class="form-check form-check-inline">
|
63
|
+
<%= form.radio_button :select_value, SimpleDrilldown::Search::SelectValue::COUNT, class: "form-check-input", onChange: 'form.submit()' %>
|
64
|
+
<label class="form-check-label mr-3" for="search_select_value_count"><%= t(:count) %></label>
|
65
|
+
</div>
|
66
|
+
<% controller.c_summary_fields.each do |field| %>
|
67
|
+
<div class="form-check form-check-inline">
|
68
|
+
<%= form.radio_button :select_value, field, class: "form-check-input", onChange: 'form.submit()' %>
|
69
|
+
<label class="form-check-label mr-3" for="search_select_value_<%= field %>"><%= t(:field, default: field.to_s.titleize) %></label>
|
70
|
+
</div>
|
71
|
+
<% end %>
|
72
|
+
</div>
|
73
|
+
<% end %>
|
74
|
+
|
59
75
|
<%= form.check_box :order_by_value, { :onChange => 'form.submit()' } %>
|
60
76
|
<%= form.label :order_by_value, t(:order_by_value) %>
|
61
77
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
<% row_class = dimension > 0 && @dimensions[dimension - 1]&.[](:row_class)&.call(result[:value]) %>
|
1
2
|
<% if new_row -%>
|
2
3
|
<tr class="<%= cycle("odd", "even", :name => "dim#{dimension}") %>">
|
3
4
|
<% ((dimension + 1)..(@dimensions.size)).each { |i| cycle("odd", "even", :name => "dim#{i}") if current_cycle("dim#{i}") != current_cycle("dim#{dimension}") } -%>
|
@@ -14,5 +15,13 @@
|
|
14
15
|
(<%= 100 * result[:count] / parent_result[:count] %>%)
|
15
16
|
<% end %>
|
16
17
|
</td>
|
18
|
+
<% controller.c_summary_fields.each do |summary_field| %>
|
19
|
+
<td class="<%=row_class%>" align="right">
|
20
|
+
<%= result[summary_field] %>
|
21
|
+
<% if @search.percent && parent_result && parent_result[summary_field] > 0 %>
|
22
|
+
(<%= 100 * result[summary_field] / parent_result[summary_field] %>%)
|
23
|
+
<% end %>
|
24
|
+
</td>
|
25
|
+
<% end %>
|
17
26
|
</tr>
|
18
27
|
<% end %>
|
@@ -12,6 +12,15 @@ class <%= class_name %>DrilldownController < SimpleDrilldown::Controller
|
|
12
12
|
# How should we count the reords?
|
13
13
|
# select 'count(*) as count'
|
14
14
|
|
15
|
+
# Multiple select values:
|
16
|
+
# select <<~SQL
|
17
|
+
# COUNT(*) as count,
|
18
|
+
# sum(hours) as hours,
|
19
|
+
# sum(billable_hours) as billable_hours
|
20
|
+
# SQL
|
21
|
+
# summary_fields :hours, :billable_hours
|
22
|
+
# default_select_value :billable_hours
|
23
|
+
|
15
24
|
# When selecting records, what relations should be included for optimization?
|
16
25
|
# Other relations can be included for specific dimensions and fields.
|
17
26
|
# base_includes :user, :comments # TODO(uwe): Read relations from schema?
|
@@ -58,7 +58,7 @@ module SimpleDrilldown
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def default_select_value(default_select_value)
|
61
|
-
self.c_default_select_value = default_select_value
|
61
|
+
self.c_default_select_value = default_select_value.to_sym
|
62
62
|
end
|
63
63
|
|
64
64
|
def target_class(target_class)
|
@@ -327,16 +327,7 @@ module SimpleDrilldown
|
|
327
327
|
includes.flatten!
|
328
328
|
includes.keep_if(&:present?).uniq!
|
329
329
|
if @search.order_by_value && @dimensions.size <= 1
|
330
|
-
order =
|
331
|
-
when Search::SelectValue::VOLUME
|
332
|
-
'volume DESC'
|
333
|
-
when Search::SelectValue::VOLUME_COMPENSATED
|
334
|
-
'volume_compensated DESC'
|
335
|
-
when Search::SelectValue::COUNT
|
336
|
-
'count DESC'
|
337
|
-
else
|
338
|
-
'count DESC'
|
339
|
-
end
|
330
|
+
order = "#{c_summary_fields.find { |f| f == @search.select_value } || 'count'} DESC"
|
340
331
|
else
|
341
332
|
order = (1..@dimensions.size).map { |i| "value#{i}" }.join(',')
|
342
333
|
order = nil if order.empty?
|
@@ -14,9 +14,7 @@ module SimpleDrilldown
|
|
14
14
|
end
|
15
15
|
|
16
16
|
module SelectValue
|
17
|
-
COUNT =
|
18
|
-
VOLUME = 'VOLUME'
|
19
|
-
VOLUME_COMPENSATED = 'VOLUME_COMPENSATED'
|
17
|
+
COUNT = :count
|
20
18
|
end
|
21
19
|
|
22
20
|
attr_reader :dimensions, :display_type, :fields, :filter, :list_change_times, :order_by_value,
|
@@ -62,7 +60,7 @@ module SimpleDrilldown
|
|
62
60
|
@display_type = DisplayType::BAR if @dimensions.size >= 2 && @display_type == DisplayType::PIE
|
63
61
|
|
64
62
|
@order_by_value = attributes && (attributes[:order_by_value] == '1')
|
65
|
-
@select_value = attributes&.dig(:select_value).
|
63
|
+
@select_value = attributes&.dig(:select_value).presence&.to_sym || @default_select_value
|
66
64
|
@list = attributes&.[](:list) == '1'
|
67
65
|
@percent = attributes&.[](:percent) == '1'
|
68
66
|
@list_change_times = attributes&.[](:list_change_times) == '1'
|
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.9.
|
4
|
+
version: 0.9.5
|
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-05-
|
11
|
+
date: 2021-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caxlsx_rails
|