simple_drilldown 0.8.3 → 0.9.4

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: e641a96b877ef453506755526c3fb0fb30974f4c8f62f837008f028d24d2e693
4
- data.tar.gz: 603066309062265101fc4c038673ddffdb37a8b03f1cabb26472534eaad2cf76
3
+ metadata.gz: a9258ecdeb91deb6d4a17a1a23e28f1e0e9cbf243588d9f40e057f93f16c0892
4
+ data.tar.gz: 5a6e71f4400c9259fe90a04420372adfd29982bede1aec6968d06050c44de9cf
5
5
  SHA512:
6
- metadata.gz: af0ea2c629a6269a1463891e065dc89e7d60c94fcd34554433ee8288dbb7210490e2fdcb5505d2bb42e9a7bddf83ee61baa0b9528307d6a2dc10784553530b7f
7
- data.tar.gz: 1f21dcf709ad307cfadc52f0a660e047ed5f44fd2aa2d77ff525ead5e3b0520ac9a58d9e83132b43ccdf29ed2583298e35b3b084bc3587c418b7da0f5ae96e34
6
+ metadata.gz: c84bcd765bdb3a7fd29a67a2401849ca065505ec888b0691f6a3b3b79cd94ad5db7a8a28a12b575f6ab6675e328209e7aaa0c13b43c52f65fe227312efaf2e41
7
+ data.tar.gz: b87a85a90e3843d4deed1aa9725e914622073e77cfdf02db5e771912bd457812a846298f171d4673ee9d6cdcf9154bd661c6a2cd651231503de227fef1422f52
@@ -16,6 +16,14 @@
16
16
  end
17
17
  %>
18
18
 
19
+ <%= render '/drilldown/tab_buttons', form: form %>
20
+
21
+ <div id="drilldown_area">
22
+ <h2><%= caption %></h2>
23
+ <h3><%= subcaption %></h3>
24
+ <br/>
25
+ </div>
26
+
19
27
  <%
20
28
  case @search.display_type
21
29
  when SimpleDrilldown::Search::DisplayType::PIE
@@ -25,12 +33,6 @@
25
33
  <%= column_chart data, height: '24rem' %>
26
34
  <% when SimpleDrilldown::Search::DisplayType::LINE %>
27
35
  <%= line_chart data, height: '24rem' %>
28
- <% else %>
29
- <div id="drilldown_area">
30
- <h2><%= caption %></h2>
31
- <h3><%= subcaption %></h3>
32
- <br/>
33
- </div>
34
36
  <% end %>
35
37
 
36
38
  <div id="drilldown_search_area" style="margin-left: auto; margin-right: auto; text-align: center">
@@ -66,10 +68,10 @@
66
68
  <%= javascript_tag do %>
67
69
  $('#chart-1').on('click', function(e){
68
70
  chart = Chartkick.charts['chart-1'].getChartObject();
69
- firstPoint = chart.getElementsAtEvent(e)[0]
71
+ firstPoint = chart.getElementsAtEventForMode(e, 'nearest', { intersect: true }, false)[0]
70
72
  if (firstPoint) {
71
- label = chart.data.labels[firstPoint._index];
72
- value = chart.data.datasets[firstPoint._datasetIndex].data[firstPoint._index];
73
+ label = chart.data.labels[firstPoint.index];
74
+ value = chart.data.datasets[firstPoint.datasetIndex].data[firstPoint._index];
73
75
  console.log("Label: " + label + ", Value: " + value);
74
76
  new_location = window.location.toString();
75
77
  new_location = new_location.replace(/#.*$/, '');
@@ -3,7 +3,7 @@
3
3
  def excel_header_row(sheet)
4
4
  padding_cells = @dimensions.empty? ? 1 : @dimensions.size
5
5
  row = (1...(padding_cells - 1)).map { |_n| nil }
6
- @search.fields.each_with_index { |field, _i| row << t(field) }
6
+ @search.fields.each_with_index { |field, _i| row << t(field, default: field.titleize) }
7
7
  sheet.add_row row
8
8
  end
9
9
 
@@ -1,28 +1,20 @@
1
1
  <% if dimension_name == 'calendar_date' %>
2
2
  <% dates = [*@search.filter[dimension_name]] %>
3
- <tr>
4
- <td align="right" valign="top">
5
- <%= form.label "filter[calendar_date]", t(:from_date) %>
6
- </td>
7
- <td>
8
- <input type="text" data-behaviour="datepicker" id="search_filter[from_<%= dimension_name %>]"
9
- name="search[filter][<%= dimension_name %>][]" class="form-control" value="<%= dates[0] %>"
10
- placeholder="yyyy-mm-dd"/>
11
- </td>
12
- </tr>
13
- <tr>
14
- <td align="right" valign="top">
15
- <%= form.label "filter[calendar_date]", t(:to_date) %>
16
- </td>
17
- <td>
18
- <input type="text" data-behaviour="datepicker" id="search_filter[to_<%= dimension_name %>]"
19
- name="search[filter][<%= dimension_name %>][]" class="form-control" value="<%= dates[1] || dates[0] %>"
20
- placeholder="yyyy-mm-dd"/>
21
- </td>
22
- </tr>
3
+ <div class="form-group">
4
+ <%= form.label "filter[calendar_date]", t(:from_date) %>
5
+ <input type="text" data-behaviour="datepicker" id="search_filter[from_<%= dimension_name %>]"
6
+ name="search[filter][<%= dimension_name %>][]" class="form-control date" value="<%= dates[0] %>"
7
+ placeholder="yyyy-mm-dd"/>
8
+ </div>
9
+ <div class="form-group">
10
+ <%= form.label "filter[calendar_date]", t(:to_date) %>
11
+ <input type="text" data-behaviour="datepicker" id="search_filter[to_<%= dimension_name %>]"
12
+ name="search[filter][<%= dimension_name %>][]" class="form-control date" value="<%= dates[1] %>"
13
+ placeholder="yyyy-mm-dd"/>
14
+ </div>
23
15
  <% else %>
24
16
  <div class="form-group">
25
- <%= form.label "filter[#{dimension_name}]", t(dimension_name, default: :"activerecord.models.#{dimension_name}") %>
17
+ <%= form.label "filter[#{dimension_name}]", t(dimension_name, default: [:"activerecord.models.#{dimension_name}", dimension_name.titleize]) %>
26
18
  <%= select :search, :filter,
27
19
  choices,
28
20
  { :selected => @search.filter[dimension_name] },
@@ -2,7 +2,7 @@
2
2
  <tr>
3
3
  <td colspan="<%= controller.c_summary_fields.size + 1 %>">
4
4
  <table id="drilldown-records-<%= result[:value] %>" class="table table-condensed table-bordered" style="padding-bottom: 10px;">
5
- <%= render :partial => '/drilldown/row_header' %>
5
+ <%= render '/drilldown/row_header', records: result[:records] %>
6
6
  <tbody>
7
7
  <% result[:records].each do |t| %>
8
8
  <%= render :partial => '/drilldown/row', :locals => { :transaction => t, :previous_transaction => nil, :errors => [], :error_row => false, :meter1_errors => false } %>
@@ -1,8 +1,10 @@
1
1
  <thead>
2
2
  <tr>
3
3
  <% @search.fields.each do |field| %>
4
- <th><%=t field, default: :"attributes.#{field}" %></th>
4
+ <th><%= t field, default: :"attributes.#{field}" %></th>
5
5
  <% end %>
6
- <th></th>
6
+ <th>
7
+ <%= render 'drilldown/export_links', records: records %>
8
+ </th>
7
9
  </tr>
8
10
  </thead>
@@ -1,5 +1,4 @@
1
- <div style="float:right">
2
- <%= form.submit t(:search), class: 'btn btn-default' %>
3
- <a href="<%= url_for() %>" class="btn btn-default"><%= t :reset %></a>
1
+ <div class="float-right">
2
+ <%= form.submit t(:search), class: 'btn btn-primary' %>
3
+ <a href="<%= url_for %>" class="btn btn-warning"><%= t :reset %></a>
4
4
  </div>
5
- <br clear="right"/>
@@ -1,16 +1,15 @@
1
- <% @page_title = "#{caption} #{subcaption}" %>
2
1
  <%= javascript_include_tag 'chartkick' %>
3
2
  <%= stylesheet_link_tag 'simple_drilldown/application' %>
4
- <style type="text/css">
5
- table#drill_down_layout > tbody > tr > td {
6
- border: none;
7
- font-size: 13px
8
- }
3
+ <style>
4
+ table#drill_down_layout > tbody > tr > td {
5
+ border: none;
6
+ font-size: 13px
7
+ }
9
8
 
10
- table#drill_down_layout td {
11
- padding: 2px;
12
- line-height: 18px
13
- }
9
+ table#drill_down_layout td {
10
+ padding: 2px;
11
+ line-height: 18px
12
+ }
14
13
  </style>
15
14
 
16
15
  <%= form_for @search, html: { id: 'edit_search_SEARCH', method: :get, class: :search, style: 'background: inherit', onsubmit: 'return this.submit()' }, url: {} do |form| %>
@@ -26,11 +25,9 @@
26
25
  <!-- Tab panes -->
27
26
  <div class="tab-content">
28
27
  <div class="tab-pane active" id="filter">
29
- <%= render '/drilldown/tab_buttons', form: form %>
30
28
  <%= render '/drilldown/filter', form: form %>
31
29
  </div>
32
30
  <div class="tab-pane" id="fields">
33
- <%= render '/drilldown/tab_buttons', form: form %>
34
31
  <%= render '/drilldown/fields', form: form %>
35
32
  </div>
36
33
  </div>
@@ -46,7 +43,7 @@
46
43
  <div class="row">
47
44
  <div class="col-md-12" valign="top">
48
45
  <div style="float: right; clear: both;">
49
- <%= render '/drilldown/export_links' %>
46
+ <%= render '/drilldown/export_links', records: @result[:records] %>
50
47
  </div>
51
48
  <%= render '/drilldown/summary_table' %>
52
49
  </div>
@@ -1,15 +1,12 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Simple drilldown</title>
5
- <%= csrf_meta_tags %>
6
- <%= csp_meta_tag %>
7
-
8
- <%= stylesheet_link_tag "simple_drilldown/application", media: "all" %>
9
- </head>
10
- <body>
11
-
12
- <%= yield %>
13
-
14
- </body>
3
+ <head>
4
+ <title>Simple drilldown</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+ <%= stylesheet_link_tag "simple_drilldown/application", media: "all" %>
8
+ </head>
9
+ <body>
10
+ <%= yield %>
11
+ </body>
15
12
  </html>
@@ -45,8 +45,8 @@ module SimpleDrilldown
45
45
  self.c_base_condition = base_condition
46
46
  end
47
47
 
48
- def base_includes(base_includes)
49
- self.c_base_includes = base_includes
48
+ def base_includes(*base_includes)
49
+ self.c_base_includes = base_includes.flatten
50
50
  end
51
51
 
52
52
  def base_group(base_group)
@@ -69,7 +69,7 @@ module SimpleDrilldown
69
69
  self.c_select = select
70
70
  end
71
71
 
72
- def list_includes(list_includes)
72
+ def list_includes(*list_includes)
73
73
  self.c_list_includes = list_includes.flatten
74
74
  end
75
75
 
@@ -128,7 +128,7 @@ module SimpleDrilldown
128
128
  interval: interval,
129
129
  label_method: label_method,
130
130
  legal_values: legal_values,
131
- pretty_name: I18n.t(name, default: :"activerecord.models.#{name}"),
131
+ pretty_name: I18n.t(name, default: [:"activerecord.models.#{name}", name.to_s.titleize]),
132
132
  queries: queries,
133
133
  reverse: reverse,
134
134
  select_expression:
@@ -192,9 +192,6 @@ module SimpleDrilldown
192
192
 
193
193
  values = Array(values)
194
194
  if dimension_def[:interval]
195
- values *= 2 if values.size == 1
196
- raise "Need 2 values for interval filter: #{values.inspect}" if values.size != 2
197
-
198
195
  if values[0].present? && values[1].present?
199
196
  condition_strings << "#{dimension_def[:select_expression]} BETWEEN ? AND ?"
200
197
  condition_values += values
@@ -263,7 +260,9 @@ module SimpleDrilldown
263
260
  include_alias = include.to_s.pluralize
264
261
  case ass.macro
265
262
  when :belongs_to
266
- "LEFT JOIN #{include_table} #{include_alias} ON #{include_alias}.id = #{model_table}.#{include}_id"
263
+ pk_col = ass.association_primary_key
264
+ fk_col = ass.options[:foreign_key] || "#{include}_id"
265
+ "LEFT JOIN #{include_table} #{include_alias} ON #{include_alias}.#{pk_col} = #{model_table}.#{fk_col}"
267
266
  when :has_one, :has_many
268
267
  fk_col = ass.options[:foreign_key] || "#{model}_id"
269
268
  sql = +"LEFT JOIN #{include_table} #{include_alias} ON #{include_alias}.#{fk_col} = #{model_table}.id"
@@ -9,7 +9,7 @@ module SimpleDrilldown
9
9
  config.autoload_paths << File.dirname(__dir__)
10
10
 
11
11
  initializer 'simple_drilldown.assets.precompile' do |app|
12
- app.config.assets.precompile += %w[chartkick.js]
12
+ app.config.assets.precompile += %w[simple_drilldown/application.css chartkick.js]
13
13
  end
14
14
 
15
15
  ActionDispatch::Routing::Mapper.include SimpleDrilldown::Routing
@@ -1,3 +1,3 @@
1
1
  module SimpleDrilldown
2
- VERSION = '0.8.3'
2
+ VERSION = '0.9.4'
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.8.3
4
+ version: 0.9.4
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-08 00:00:00.000000000 Z
11
+ date: 2021-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caxlsx_rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.3'
33
+ version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.3'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  requirements: []
173
- rubygems_version: 3.2.3
173
+ rubygems_version: 3.2.15
174
174
  signing_key:
175
175
  specification_version: 4
176
176
  summary: Simple data warehouse and drilldown.