simple_drilldown 0.6.0 → 0.6.6
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/_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/_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 +14 -18
- data/lib/simple_drilldown/controller.rb +15 -15
- data/lib/simple_drilldown/{drilldown_helper.rb → helper.rb} +1 -2
- data/lib/simple_drilldown/search.rb +4 -0
- data/lib/simple_drilldown/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7973a2345d9a18add6f71aa2e0b1d1922738b58050b93e6f3e6f325e7e6b28d
|
4
|
+
data.tar.gz: 56a5a4a4d5c60164234637e2642dc6272c4370bd5354934377d92cb8dadcfda6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99604c9bb8f933bc9772a3350816de27192d830a2849e271afe805fcef4a2b08df401fe0dc9a2b6cec4002430474562f57b2b69d37d883f5b112d7460cd8e976
|
7
|
+
data.tar.gz: e76fbaecb66361e0793adc80c90c14b497a848078b8a6d8b1ed140cf3541917c71484a0bfb7659288da591343f0044e7e0698adc2594b9712af5bb1df6fff3fb
|
@@ -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 %>
|
@@ -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
|
22
|
-
<li><a
|
20
|
+
<li class="nav-item">
|
21
|
+
<a id="filter-tab" class="nav-link active" data-target="#filter" data-toggle="tab"><%= t :filter %></a></li>
|
22
|
+
<li><a id="fields-tab" class="nav-link" data-target="#fields" data-toggle="tab"><%= t :fields %></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>
|
@@ -101,7 +97,7 @@ form.submit = function() {
|
|
101
97
|
return false;
|
102
98
|
};
|
103
99
|
|
104
|
-
$(document).ready(function () {
|
105
|
-
|
106
|
-
})
|
100
|
+
// $(document).ready(function () {
|
101
|
+
// $('[data-behaviour~=datepicker]').datepicker({format: "yyyy-mm-dd"});
|
102
|
+
// })
|
107
103
|
<% end %>
|
@@ -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
7
|
class Controller < ::ApplicationController
|
8
|
-
helper
|
8
|
+
helper Helper
|
9
9
|
|
10
10
|
LIST_LIMIT = 10_000
|
11
11
|
|
@@ -122,7 +122,7 @@ module SimpleDrilldown
|
|
122
122
|
interval: interval,
|
123
123
|
label_method: label_method,
|
124
124
|
legal_values: legal_values,
|
125
|
-
pretty_name: I18n.t(name),
|
125
|
+
pretty_name: I18n.t(name, default: :"activerecord.models.#{name}"),
|
126
126
|
queries: queries,
|
127
127
|
reverse: reverse,
|
128
128
|
select_expression: queries.size > 1 ? "COALESCE(#{queries.map { |q| q[:select] }.join(',')})" : queries[0][:select],
|
@@ -389,26 +389,26 @@ module SimpleDrilldown
|
|
389
389
|
def excel_export
|
390
390
|
index(false)
|
391
391
|
headers['Content-Type'] = 'application/vnd.ms-excel'
|
392
|
-
headers['Content-Disposition'] = 'attachment; filename="
|
392
|
+
headers['Content-Disposition'] = 'attachment; filename="drilldown.xml"'
|
393
393
|
headers['Cache-Control'] = ''
|
394
394
|
render template: '/drilldown/excel_export', layout: false
|
395
395
|
end
|
396
396
|
|
397
|
-
def
|
397
|
+
def excel_export_records
|
398
398
|
params[:search][:list] = '1'
|
399
399
|
index(false)
|
400
|
-
@
|
400
|
+
@records = get_records(@result)
|
401
401
|
headers['Content-Type'] = 'application/vnd.ms-excel'
|
402
|
-
headers['Content-Disposition'] = 'attachment; filename="
|
403
|
-
render template: '/drilldown/
|
402
|
+
headers['Content-Disposition'] = 'attachment; filename="drilldown.xml"'
|
403
|
+
render template: '/drilldown/excel_export_records', layout: false
|
404
404
|
end
|
405
405
|
|
406
406
|
def xml_export
|
407
407
|
params[:search][:list] = '1'
|
408
408
|
index(false)
|
409
|
-
@
|
409
|
+
@records = get_records(@result)
|
410
410
|
headers['Content-Type'] = 'text/xml'
|
411
|
-
headers['Content-Disposition'] = 'attachment; filename="
|
411
|
+
headers['Content-Disposition'] = 'attachment; filename="drilldown.xml"'
|
412
412
|
render template: '/drilldown/xml_export', layout: false
|
413
413
|
end
|
414
414
|
|
@@ -539,9 +539,9 @@ module SimpleDrilldown
|
|
539
539
|
end
|
540
540
|
joins = self.class.make_join([], c_target_class.name.underscore.to_sym, list_includes)
|
541
541
|
list_conditions = list_conditions(conditions, values)
|
542
|
-
base_query = c_target_class.unscoped.where(c_base_condition).joins(joins).order(
|
542
|
+
base_query = c_target_class.unscoped.where(c_base_condition).joins(joins).order(c_list_order)
|
543
543
|
base_query = base_query.where(list_conditions) if list_conditions
|
544
|
-
result[:
|
544
|
+
result[:records] = base_query.to_a
|
545
545
|
end
|
546
546
|
|
547
547
|
def merge_includes(*args)
|
@@ -594,10 +594,10 @@ module SimpleDrilldown
|
|
594
594
|
[list_conditions_string, *(conditions[1..-1] + values)]
|
595
595
|
end
|
596
596
|
|
597
|
-
def
|
598
|
-
return tree[:
|
597
|
+
def get_records(tree)
|
598
|
+
return tree[:records] if tree[:records]
|
599
599
|
|
600
|
-
tree[:rows].map { |r|
|
600
|
+
tree[:rows].map { |r| get_records(r) }.flatten
|
601
601
|
end
|
602
602
|
|
603
603
|
class ScopeHolder
|
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.6.
|
4
|
+
version: 0.6.6
|
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-09-
|
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
|
@@ -126,8 +127,8 @@ files:
|
|
126
127
|
- lib/generators/drilldown_controller/templates/drilldown_controller_test.rb.erb
|
127
128
|
- lib/simple_drilldown.rb
|
128
129
|
- lib/simple_drilldown/controller.rb
|
129
|
-
- lib/simple_drilldown/drilldown_helper.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
|