simple_drilldown 0.5.0 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/drilldown/_chart.html.erb +22 -2
- data/app/views/drilldown/_excel_record_list.builder +1 -1
- data/app/views/drilldown/_export_links.html.erb +2 -0
- data/app/views/drilldown/_field.html.erb +1 -1
- data/app/views/drilldown/_fields.html.erb +1 -1
- data/app/views/drilldown/_filter.html.erb +2 -3
- data/app/views/drilldown/_record_list.html.erb +2 -2
- data/app/views/drilldown/_row_header.html.erb +1 -1
- data/app/views/drilldown/excel_export_transactions.builder +2 -2
- data/app/views/drilldown/index.html.erb +11 -15
- data/lib/generators/drilldown_controller/USAGE +1 -0
- data/lib/generators/drilldown_controller/templates/drilldown_controller.rb.erb +2 -2
- data/lib/simple_drilldown/{drilldown_controller.rb → controller.rb} +104 -46
- data/lib/simple_drilldown/engine.rb +3 -0
- data/lib/simple_drilldown/{drilldown_helper.rb → helper.rb} +2 -2
- data/lib/simple_drilldown/routing.rb +1 -1
- data/lib/simple_drilldown/search.rb +4 -0
- data/lib/simple_drilldown/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 213cbd7d6cd897ec7b381009bef56cf5fb663a8dcaeba2ef459b84635093e59b
|
4
|
+
data.tar.gz: ebc3d77828685b892254022b471ac76f80f840963ba7e78f9ddf4cb3161e746c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f21841814f866ecdfe03b63d853dd79ff4b4f4fef5754a67ff78dbbeda1faab0c6ad9f1afe59b100087e4efbcf87de430c5fcf2a8cafbcf299401fef232d1d05
|
7
|
+
data.tar.gz: 6b227bf456e69d56902f03415c5c7cff137177f09512a8d268a97eabd2ed48d674bf5e5b25a14fed95c1c732c2b40cf178935c99c67df975e2868490373fc65f
|
@@ -20,7 +20,7 @@
|
|
20
20
|
case @search.display_type
|
21
21
|
when SimpleDrilldown::Search::DisplayType::PIE
|
22
22
|
%>
|
23
|
-
<%= pie_chart data, height: '24rem' %>
|
23
|
+
<%= pie_chart data, height: '24rem', events: ['click'] %>
|
24
24
|
<% when SimpleDrilldown::Search::DisplayType::BAR %>
|
25
25
|
<%= column_chart data, height: '24rem' %>
|
26
26
|
<% when SimpleDrilldown::Search::DisplayType::LINE %>
|
@@ -40,7 +40,7 @@
|
|
40
40
|
options += @remaining_dimensions.keys.map { |name| [controller.c_dimension_defs[name][:pretty_name], name] } %>
|
41
41
|
<%= t(i == 0 ? :group_by : :then_by) %>:
|
42
42
|
<%= form.select 'dimensions', options, { :selected => @search.dimensions && @search.dimensions[i] },
|
43
|
-
{ :
|
43
|
+
{ onChange: 'form.submit()', name: 'search[dimensions][]', id: "search_dimensions_#{i}" } %>
|
44
44
|
<% end %>
|
45
45
|
|
46
46
|
<br/>
|
@@ -60,3 +60,23 @@
|
|
60
60
|
<%= form.check_box :list, { :onChange => 'form.submit()' } %>
|
61
61
|
<%= form.label :list, t(:list) %>
|
62
62
|
</div>
|
63
|
+
|
64
|
+
<% if @dimensions.size == 1 &&
|
65
|
+
[SimpleDrilldown::Search::DisplayType::BAR, SimpleDrilldown::Search::DisplayType::PIE].include?(@search.display_type) %>
|
66
|
+
<%= javascript_tag do %>
|
67
|
+
$('#chart-1').on('click', function(e){
|
68
|
+
chart = Chartkick.charts['chart-1'].getChartObject();
|
69
|
+
firstPoint = chart.getElementsAtEvent(e)[0]
|
70
|
+
if (firstPoint) {
|
71
|
+
label = chart.data.labels[firstPoint._index];
|
72
|
+
value = chart.data.datasets[firstPoint._datasetIndex].data[firstPoint._index];
|
73
|
+
console.log("Label: " + label + ", Value: " + value);
|
74
|
+
new_location = window.location.toString();
|
75
|
+
new_location = new_location.replace("&search[dimensions][]=<%= @dimensions[0][:url_param_name] %>", '');
|
76
|
+
new_location = new_location + '&search[filter][<%= @dimensions[0][:url_param_name] %>][]=' + label;
|
77
|
+
console.log(new_location);
|
78
|
+
window.location = new_location;
|
79
|
+
}
|
80
|
+
});
|
81
|
+
<% end %>
|
82
|
+
<% end %>
|
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
xml << render(partial: '/drilldown/excel_row_header')
|
4
4
|
|
5
|
-
result[:
|
5
|
+
result[:records].each do |t|
|
6
6
|
xml << render(partial: '/drilldown/excel_row', locals: { transaction: t, previous_transaction: nil, errors: [], error_row: false, meter1_errors: false })
|
7
7
|
end
|
@@ -0,0 +1,2 @@
|
|
1
|
+
<%= link_to 'Excel', @search.url_options.merge(action: :excel_export) %> |
|
2
|
+
<%= link_to 'HTML', @search.url_options.merge(action: :html_export), data_popup: ['Elections', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=1024px'] %>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
</tr>
|
23
23
|
<% else %>
|
24
24
|
<div class="form-group">
|
25
|
-
<%= form.label "filter[#{dimension_name}]", t(dimension_name) %>
|
25
|
+
<%= form.label "filter[#{dimension_name}]", t(dimension_name, default: :"activerecord.models.#{dimension_name}") %>
|
26
26
|
<%= select :search, :filter,
|
27
27
|
choices,
|
28
28
|
{ :selected => @search.filter[dimension_name] },
|
@@ -6,7 +6,7 @@
|
|
6
6
|
</style>
|
7
7
|
|
8
8
|
<% @transaction_fields.each do | field | %>
|
9
|
-
<%=form.label "fields[#{field}]", t(field), :class => "field_label" %>
|
9
|
+
<%=form.label "fields[#{field}]", t(field, default: :"attributes.#{field}"), :class => "field_label" %>
|
10
10
|
<%=form.check_box :fields, :id => "search_fields[#{field}]", :name => "search[fields][#{field}]", :checked => @search.fields.include?(field) %>
|
11
11
|
<br/>
|
12
12
|
<% end %>
|
@@ -3,9 +3,8 @@
|
|
3
3
|
<%= form.text_field :title, class: 'form-control' %>
|
4
4
|
</div>
|
5
5
|
|
6
|
-
<% choices = Concurrent::Hash.new %>
|
7
6
|
<% controller.c_dimension_defs.each do |dimension_name, dimension| %>
|
8
|
-
<% choices
|
9
|
-
<%= render partial: 'drilldown/field', locals: { choices: choices
|
7
|
+
<% choices = [[t(:all), nil]] + (dimension[:legal_values] && dimension[:legal_values].call(@search).map { |o| o.is_a?(Array) ? [o[0].to_s, o[1].to_s] : o.to_s } || []) %>
|
8
|
+
<%= render partial: 'drilldown/field', locals: { choices: choices || [],
|
10
9
|
form: form, dimension_name: dimension_name } %>
|
11
10
|
<% end %>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
<% unless result[:
|
1
|
+
<% unless result[:records].empty? %>
|
2
2
|
<tr>
|
3
3
|
<td colspan="<%= controller.c_summary_fields.size + 1 %>">
|
4
4
|
<table class="table table-condensed table-bordered" style="padding-bottom: 10px;">
|
5
5
|
<%= render :partial => '/drilldown/row_header' %>
|
6
|
-
<% result[:
|
6
|
+
<% result[:records].each do |t| %>
|
7
7
|
<%= render :partial => '/drilldown/row', :locals => { :transaction => t, :previous_transaction => nil, :errors => [], :error_row => false, :meter1_errors => false } %>
|
8
8
|
<% end %>
|
9
9
|
</table>
|
@@ -12,7 +12,7 @@ xml.Workbook(
|
|
12
12
|
) do
|
13
13
|
xml << render(partial: '/layouts/excel_styles')
|
14
14
|
|
15
|
-
xml.Worksheet 'ss:Name' => '
|
15
|
+
xml.Worksheet 'ss:Name' => 'Drilldown' do
|
16
16
|
xml.Table do
|
17
17
|
xml.Row 'ss:Height' => '18.75' do
|
18
18
|
xml.Cell 'ss:MergeAcross' => '35', 'ss:StyleID' => 'MainTitle' do
|
@@ -42,7 +42,7 @@ xml.Workbook(
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
@
|
45
|
+
@records.each do |transaction|
|
46
46
|
xml.Row do
|
47
47
|
@transaction_fields.each do |field|
|
48
48
|
field_map = controller.c_fields[field.to_sym]
|
@@ -13,25 +13,25 @@
|
|
13
13
|
}
|
14
14
|
</style>
|
15
15
|
|
16
|
-
<%= form_for @search, :
|
16
|
+
<%= form_for @search, html: { id: 'edit_search_SEARCH', method: :get, class: :search, style: 'background: inherit', onsubmit: 'return this.submit()' }, url: {} do |form| %>
|
17
17
|
<div class="row">
|
18
18
|
<div class="col-md-3" valign="top">
|
19
19
|
<ul class="nav nav-tabs">
|
20
|
-
<li class="
|
21
|
-
<a href="#filter" data-toggle="tab"><em><%= t :filter %></em></a></li>
|
22
|
-
<li><a href="#fields" data-toggle="tab"><em><%= t :fields %></em></a>
|
20
|
+
<li class="nav-item">
|
21
|
+
<a class="nav-link active" href="#filter" data-toggle="tab"><em><%= t :filter %></em></a></li>
|
22
|
+
<li><a class="nav-link" href="#fields" data-toggle="tab"><em><%= t :fields %></em></a>
|
23
23
|
</li>
|
24
24
|
</ul>
|
25
25
|
|
26
26
|
<!-- Tab panes -->
|
27
27
|
<div class="tab-content">
|
28
28
|
<div class="tab-pane active" id="filter">
|
29
|
-
<%= render
|
30
|
-
<%= render
|
29
|
+
<%= render '/drilldown/tab_buttons', form: form %>
|
30
|
+
<%= render '/drilldown/filter', form: form %>
|
31
31
|
</div>
|
32
32
|
<div class="tab-pane" id="fields">
|
33
|
-
<%= render
|
34
|
-
<%= render
|
33
|
+
<%= render '/drilldown/tab_buttons', form: form %>
|
34
|
+
<%= render '/drilldown/fields', form: form %>
|
35
35
|
</div>
|
36
36
|
</div>
|
37
37
|
|
@@ -39,20 +39,16 @@
|
|
39
39
|
<div class="col-md-9">
|
40
40
|
<div class="row" valign="top">
|
41
41
|
<div class="col-md-12">
|
42
|
-
<%= render
|
43
|
-
<br/>
|
42
|
+
<%= render '/drilldown/chart', form: form %>
|
44
43
|
</div>
|
45
44
|
</div>
|
46
45
|
|
47
46
|
<div class="row">
|
48
47
|
<div class="col-md-12" valign="top">
|
49
48
|
<div style="float: right; clear: both;">
|
50
|
-
<%=
|
51
|
-
<%= link_to 'HTML', @search.url_options.merge(action: :html_export), :data_popup => ['Elections', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=1024px'] %>
|
49
|
+
<%= render '/drilldown/export_links' %>
|
52
50
|
</div>
|
53
|
-
|
54
|
-
|
55
|
-
<%= render :partial => '/drilldown/summary_table' %>
|
51
|
+
<%= render '/drilldown/summary_table' %>
|
56
52
|
</div>
|
57
53
|
</div>
|
58
54
|
</div>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'simple_drilldown/
|
3
|
+
require 'simple_drilldown/controller'
|
4
4
|
|
5
|
-
class <%= class_name %>DrilldownController < SimpleDrilldown::
|
5
|
+
class <%= class_name %>DrilldownController < SimpleDrilldown::Controller
|
6
6
|
# The main focus of the drilldown
|
7
7
|
# target_class <%= class_name %>
|
8
8
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'simple_drilldown/
|
3
|
+
require 'simple_drilldown/helper'
|
4
4
|
require 'simple_drilldown/search'
|
5
5
|
|
6
6
|
module SimpleDrilldown
|
7
|
-
class
|
8
|
-
helper
|
7
|
+
class Controller < ::ApplicationController
|
8
|
+
helper Helper
|
9
9
|
|
10
10
|
LIST_LIMIT = 10_000
|
11
11
|
|
@@ -14,8 +14,8 @@ module SimpleDrilldown
|
|
14
14
|
class_attribute :c_base_includes, default: []
|
15
15
|
class_attribute :c_default_fields, default: []
|
16
16
|
class_attribute :c_default_select_value, default: SimpleDrilldown::Search::SelectValue::COUNT
|
17
|
-
class_attribute :c_dimension_defs
|
18
|
-
class_attribute :c_fields
|
17
|
+
class_attribute :c_dimension_defs
|
18
|
+
class_attribute :c_fields
|
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'
|
@@ -25,7 +25,16 @@ module SimpleDrilldown
|
|
25
25
|
class << self
|
26
26
|
def inherited(base)
|
27
27
|
super
|
28
|
-
base.
|
28
|
+
base.c_dimension_defs = Concurrent::Hash.new
|
29
|
+
base.c_fields = {}
|
30
|
+
begin
|
31
|
+
base.c_target_class = base.name.chomp('DrilldownController').constantize
|
32
|
+
rescue NameError
|
33
|
+
begin
|
34
|
+
base.c_target_class = base.name.chomp('Controller').constantize
|
35
|
+
rescue NameError
|
36
|
+
end
|
37
|
+
end
|
29
38
|
end
|
30
39
|
|
31
40
|
def base_condition(base_condition)
|
@@ -41,7 +50,11 @@ module SimpleDrilldown
|
|
41
50
|
end
|
42
51
|
|
43
52
|
def default_fields(default_fields)
|
44
|
-
self.c_default_fields = default_fields
|
53
|
+
self.c_default_fields = default_fields.flatten
|
54
|
+
end
|
55
|
+
|
56
|
+
def default_select_value(default_select_value)
|
57
|
+
self.c_default_select_value = default_select_value
|
45
58
|
end
|
46
59
|
|
47
60
|
def target_class(target_class)
|
@@ -53,7 +66,7 @@ module SimpleDrilldown
|
|
53
66
|
end
|
54
67
|
|
55
68
|
def list_includes(list_includes)
|
56
|
-
self.c_list_includes = list_includes
|
69
|
+
self.c_list_includes = list_includes.flatten
|
57
70
|
end
|
58
71
|
|
59
72
|
def list_order(list_order)
|
@@ -65,7 +78,7 @@ module SimpleDrilldown
|
|
65
78
|
end
|
66
79
|
|
67
80
|
def summary_fields(*summary_fields)
|
68
|
-
self.c_summary_fields = summary_fields
|
81
|
+
self.c_summary_fields = summary_fields.flatten
|
69
82
|
end
|
70
83
|
|
71
84
|
def dimension(name, select_expression = name, options = {})
|
@@ -92,17 +105,24 @@ module SimpleDrilldown
|
|
92
105
|
end
|
93
106
|
|
94
107
|
c_dimension_defs[name.to_s] = {
|
95
|
-
includes: queries.inject(
|
108
|
+
includes: queries.inject(nil) do |a, e|
|
96
109
|
i = e[:includes]
|
97
110
|
next a unless i
|
98
|
-
next a if a
|
111
|
+
next a if a&.include?(i)
|
99
112
|
|
100
|
-
a
|
113
|
+
case a
|
114
|
+
when nil
|
115
|
+
i
|
116
|
+
when Symbol
|
117
|
+
[a, *i]
|
118
|
+
else
|
119
|
+
a.concat(*i)
|
120
|
+
end
|
101
121
|
end,
|
102
122
|
interval: interval,
|
103
123
|
label_method: label_method,
|
104
124
|
legal_values: legal_values,
|
105
|
-
pretty_name: I18n.t(name),
|
125
|
+
pretty_name: I18n.t(name, default: :"activerecord.models.#{name}"),
|
106
126
|
queries: queries,
|
107
127
|
reverse: reverse,
|
108
128
|
select_expression: queries.size > 1 ? "COALESCE(#{queries.map { |q| q[:select] }.join(',')})" : queries[0][:select],
|
@@ -217,9 +237,9 @@ module SimpleDrilldown
|
|
217
237
|
when Hash
|
218
238
|
sql = +''
|
219
239
|
include.each do |parent, child|
|
220
|
-
sql << make_join(joins, model, parent)
|
240
|
+
sql << ' ' + make_join(joins, model, parent)
|
221
241
|
ass = model.to_s.camelize.constantize.reflect_on_association parent
|
222
|
-
sql << make_join(joins, parent, child, ass.class_name.constantize)
|
242
|
+
sql << ' ' + make_join(joins, parent, child, ass.class_name.constantize)
|
223
243
|
end
|
224
244
|
sql
|
225
245
|
when Symbol
|
@@ -369,26 +389,26 @@ module SimpleDrilldown
|
|
369
389
|
def excel_export
|
370
390
|
index(false)
|
371
391
|
headers['Content-Type'] = 'application/vnd.ms-excel'
|
372
|
-
headers['Content-Disposition'] = 'attachment; filename="
|
392
|
+
headers['Content-Disposition'] = 'attachment; filename="drilldown.xml"'
|
373
393
|
headers['Cache-Control'] = ''
|
374
394
|
render template: '/drilldown/excel_export', layout: false
|
375
395
|
end
|
376
396
|
|
377
|
-
def
|
397
|
+
def excel_export_records
|
378
398
|
params[:search][:list] = '1'
|
379
399
|
index(false)
|
380
|
-
@
|
400
|
+
@records = get_records(@result)
|
381
401
|
headers['Content-Type'] = 'application/vnd.ms-excel'
|
382
|
-
headers['Content-Disposition'] = 'attachment; filename="
|
383
|
-
render template: '/drilldown/
|
402
|
+
headers['Content-Disposition'] = 'attachment; filename="drilldown.xml"'
|
403
|
+
render template: '/drilldown/excel_export_records', layout: false
|
384
404
|
end
|
385
405
|
|
386
406
|
def xml_export
|
387
407
|
params[:search][:list] = '1'
|
388
408
|
index(false)
|
389
|
-
@
|
409
|
+
@records = get_records(@result)
|
390
410
|
headers['Content-Type'] = 'text/xml'
|
391
|
-
headers['Content-Disposition'] = 'attachment; filename="
|
411
|
+
headers['Content-Disposition'] = 'attachment; filename="drilldown.xml"'
|
392
412
|
render template: '/drilldown/xml_export', layout: false
|
393
413
|
end
|
394
414
|
|
@@ -498,31 +518,69 @@ module SimpleDrilldown
|
|
498
518
|
|
499
519
|
def populate_list(conditions, includes, result, values)
|
500
520
|
if result[:rows]
|
501
|
-
result[:rows].each
|
502
|
-
|
521
|
+
return result[:rows].each { |r| populate_list(conditions, includes, r, values + [r[:value]]) }
|
522
|
+
end
|
523
|
+
list_includes = merge_includes(includes, c_list_includes)
|
524
|
+
@search.fields.each do |field|
|
525
|
+
field_def = c_fields[field.to_sym]
|
526
|
+
raise "Field definition missing for: #{field.inspect}" unless field_def
|
527
|
+
|
528
|
+
field_includes = field_def[:include]
|
529
|
+
if field_includes
|
530
|
+
list_includes = merge_includes(list_includes , field_includes)
|
503
531
|
end
|
504
|
-
|
505
|
-
|
506
|
-
@
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
field_includes = field_def[:include]
|
511
|
-
if field_includes
|
512
|
-
list_includes += field_includes.is_a?(Array) ? field_includes : [field_includes]
|
532
|
+
end
|
533
|
+
if @search.list_change_times
|
534
|
+
@history_fields.each do |f|
|
535
|
+
if @search.fields.include? f
|
536
|
+
list_includes = merge_includes(list_includes, assignment: { order: :"#{f}_changes" } )
|
513
537
|
end
|
514
538
|
end
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
539
|
+
end
|
540
|
+
joins = self.class.make_join([], c_target_class.name.underscore.to_sym, list_includes)
|
541
|
+
list_conditions = list_conditions(conditions, values)
|
542
|
+
base_query = c_target_class.unscoped.where(c_base_condition).joins(joins).order(c_list_order)
|
543
|
+
base_query = base_query.where(list_conditions) if list_conditions
|
544
|
+
result[:records] = base_query.to_a
|
545
|
+
end
|
546
|
+
|
547
|
+
def merge_includes(*args)
|
548
|
+
hash = hash_includes(*args)
|
549
|
+
result = hash.dup.map { |k, v|
|
550
|
+
if v.blank?
|
551
|
+
hash.delete(k)
|
552
|
+
k
|
553
|
+
end
|
554
|
+
}.compact
|
555
|
+
result << hash unless hash.blank?
|
556
|
+
case result.size
|
557
|
+
when 0
|
558
|
+
nil
|
559
|
+
when 1
|
560
|
+
result[0]
|
561
|
+
else
|
562
|
+
result
|
563
|
+
end
|
564
|
+
end
|
565
|
+
|
566
|
+
def hash_includes(*args)
|
567
|
+
args.inject({}) do |h, inc|
|
568
|
+
case inc
|
569
|
+
when Array
|
570
|
+
inc.each { |v|
|
571
|
+
h = hash_includes(h, v)
|
572
|
+
}
|
573
|
+
when Hash
|
574
|
+
inc.each { |k, v|
|
575
|
+
h[k] = merge_includes(h[k], v)
|
576
|
+
}
|
577
|
+
when NilClass, FalseClass
|
578
|
+
when String, Symbol
|
579
|
+
h[inc] ||= []
|
580
|
+
else
|
581
|
+
raise "Unknown include type: #{inc.inspect}"
|
520
582
|
end
|
521
|
-
|
522
|
-
list_conditions = list_conditions(conditions, values)
|
523
|
-
base_query = c_target_class.unscoped.where(c_base_condition).joins(joins).order(@list_order)
|
524
|
-
base_query = base_query.where(list_conditions) if list_conditions
|
525
|
-
result[:transactions] = base_query.to_a
|
583
|
+
h
|
526
584
|
end
|
527
585
|
end
|
528
586
|
|
@@ -536,10 +594,10 @@ module SimpleDrilldown
|
|
536
594
|
[list_conditions_string, *(conditions[1..-1] + values)]
|
537
595
|
end
|
538
596
|
|
539
|
-
def
|
540
|
-
return tree[:
|
597
|
+
def get_records(tree)
|
598
|
+
return tree[:records] if tree[:records]
|
541
599
|
|
542
|
-
tree[:rows].map { |r|
|
600
|
+
tree[:rows].map { |r| get_records(r) }.flatten
|
543
601
|
end
|
544
602
|
|
545
603
|
class ScopeHolder
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'chartkick'
|
4
|
+
require 'simple_drilldown/routing'
|
4
5
|
|
5
6
|
module SimpleDrilldown
|
6
7
|
class Engine < ::Rails::Engine
|
@@ -10,5 +11,7 @@ module SimpleDrilldown
|
|
10
11
|
initializer 'simple_drilldown.assets.precompile' do |app|
|
11
12
|
app.config.assets.precompile += %w[chartkick.js]
|
12
13
|
end
|
14
|
+
|
15
|
+
ActionDispatch::Routing::Mapper.include SimpleDrilldown::Routing
|
13
16
|
end
|
14
17
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module SimpleDrilldown
|
4
4
|
# View helper for SimpleDrilldown
|
5
|
-
module
|
5
|
+
module Helper
|
6
6
|
def value_label(dimension_index, value)
|
7
7
|
dimension = @dimensions[dimension_index]
|
8
8
|
return nil if dimension.nil?
|
@@ -11,7 +11,7 @@ module SimpleDrilldown
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def caption
|
14
|
-
result = @search.title || "#{
|
14
|
+
result = @search.title || "#{controller.c_target_class} #{t(@search.select_value.downcase)}" +
|
15
15
|
(@dimensions && @dimensions.any? ? ' by ' + @dimensions.map { |d| d[:pretty_name] }.join(' and ') : '')
|
16
16
|
result.gsub('$date', [*@search.filter[:calendar_date]].uniq.join(' - '))
|
17
17
|
end
|
@@ -6,7 +6,7 @@ module SimpleDrilldown
|
|
6
6
|
def draw_drilldown(path, controller = path)
|
7
7
|
get "#{path}(.:format)" => "#{controller}#index", as: path
|
8
8
|
scope path do
|
9
|
-
%i[excel_export html_export index].each do |action|
|
9
|
+
%i[choices excel_export html_export index].each do |action|
|
10
10
|
get "#{action}(/:id)(.:format)", controller: controller, action: action
|
11
11
|
end
|
12
12
|
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.5
|
4
|
+
version: 0.6.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: 2020-
|
11
|
+
date: 2020-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- app/views/drilldown/_excel_styles.builder
|
98
98
|
- app/views/drilldown/_excel_summary_row.builder
|
99
99
|
- app/views/drilldown/_excel_summary_total_row.builder
|
100
|
+
- app/views/drilldown/_export_links.html.erb
|
100
101
|
- app/views/drilldown/_field.html.erb
|
101
102
|
- app/views/drilldown/_fields.html.erb
|
102
103
|
- app/views/drilldown/_filter.html.erb
|
@@ -125,9 +126,9 @@ files:
|
|
125
126
|
- lib/generators/drilldown_controller/templates/drilldown_controller.rb.erb
|
126
127
|
- lib/generators/drilldown_controller/templates/drilldown_controller_test.rb.erb
|
127
128
|
- lib/simple_drilldown.rb
|
128
|
-
- lib/simple_drilldown/
|
129
|
-
- lib/simple_drilldown/drilldown_helper.rb
|
129
|
+
- lib/simple_drilldown/controller.rb
|
130
130
|
- lib/simple_drilldown/engine.rb
|
131
|
+
- lib/simple_drilldown/helper.rb
|
131
132
|
- lib/simple_drilldown/routing.rb
|
132
133
|
- lib/simple_drilldown/search.rb
|
133
134
|
- lib/simple_drilldown/version.rb
|