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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9258ecdeb91deb6d4a17a1a23e28f1e0e9cbf243588d9f40e057f93f16c0892
4
- data.tar.gz: 5a6e71f4400c9259fe90a04420372adfd29982bede1aec6968d06050c44de9cf
3
+ metadata.gz: 48e5faf8ea7325353ae1283ed36863a2721ba4110c883be528314b7c868af356
4
+ data.tar.gz: aaa55b27d81bef734bb52c897eff6c437c05832400fbc29bbed219ccf02e0ea3
5
5
  SHA512:
6
- metadata.gz: c84bcd765bdb3a7fd29a67a2401849ca065505ec888b0691f6a3b3b79cd94ad5db7a8a28a12b575f6ab6675e328209e7aaa0c13b43c52f65fe227312efaf2e41
7
- data.tar.gz: b87a85a90e3843d4deed1aa9725e914622073e77cfdf02db5e771912bd457812a846298f171d4673ee9d6cdcf9154bd661c6a2cd651231503de227fef1422f52
6
+ metadata.gz: a711048cd982171d465dfffc99e6155f3d22d0ca2d2c6cdb55f2be590aa76994036135e186bd7b1a5f594f9986799618208d42bd25b6e2f71452878f117e2a46
7
+ data.tar.gz: dbb15e5f741988a2b09f1cb27005d0bece4930572e24e96773752f6648608e5e88a648e0572fb3370713f5756789b543a4962f1b9320646e713cc11a9f66c71d
@@ -19,7 +19,6 @@ th.header {
19
19
  td {
20
20
  border: 1px solid #dfded2;
21
21
  padding: 2px;
22
- font-size: 10px;
23
22
  }
24
23
 
25
24
  td.numeric {
@@ -2,14 +2,14 @@
2
2
  data =
3
3
  case @dimensions.size
4
4
  when 0
5
- { @result[:value] => @result[:count] }
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[:count]] }
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[:count]] }
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 %>
@@ -1,4 +1,4 @@
1
- <table id="drilldown-summary-table" class="table table-condensed table-bordered">
1
+ <table id="drilldown-summary-table" class="table table-sm table-bordered">
2
2
  <thead>
3
3
  <tr>
4
4
  <% @dimensions.each do |d| %>
@@ -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 = case @search.select_value
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 = '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).present? ? attributes[:select_value] : @default_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'
@@ -1,3 +1,3 @@
1
1
  module SimpleDrilldown
2
- VERSION = '0.9.4'
2
+ VERSION = '0.9.5'
3
3
  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.9.4
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-21 00:00:00.000000000 Z
11
+ date: 2021-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caxlsx_rails