simple_drilldown 0.6.8 → 0.7.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: 42c85e43c9d07d94ed0d7c502afa8b4ee638f86ca41bf6b742f7f34cfd47a355
4
- data.tar.gz: 506ac06824fd78a878302544967b7f997bfae64c6e4e26da9b5955603595ffc2
3
+ metadata.gz: 1a36aab8c580f75685e00d36a6aea2bbb1b58b43c153db650ec9298cf0b5fff6
4
+ data.tar.gz: 6c1a7cda78d09fdff2519c1db52dd4c5aa7f2c7c273bc7b9f6bc730cf02b6d80
5
5
  SHA512:
6
- metadata.gz: 4dbf710685173878b38ce96238eb9c1e558bd4b9472d0f928146920f21b2de3a4eb3c64195ad87da9940383f7190c6d89404419390bce6f4fcceb134a959f634
7
- data.tar.gz: aa1f9ba981439836636dcab9a0adcd61b834f7c5e2667b86dd43980d7b3a3072f2df2b4ab6e7d6f7161fa7ed449c9473fd1a796692680dbffeb6a25e9977f0ee
6
+ metadata.gz: 587b979884e3cdb8a85fee6438358bf5ba3878ff55b1355b52e987b1b896d686558fbcde181d9c1bc1a62b0ec7a6fbe591fb36c621d59d5688e0655c31170dff
7
+ data.tar.gz: a4e90f4858363cea570a5544efb0ed45bb4ae541a4a2238511bf726755f6ced093e5f9dde0574f21f6e1b7621b9564788c9795f2ebd1e8c721014472b2f50d44
@@ -46,8 +46,7 @@ xml.Styles do
46
46
  xml.Interior 'ss:Color' => '#dedede', 'ss:Pattern' => 'Solid'
47
47
  xml.NumberFormat 'ss:Format' => "\#,\#\#0"
48
48
  end
49
- xml.Style 'ss:ID' => 'Outer' do
50
- end
49
+ xml.Style 'ss:ID' => 'Outer'
51
50
  xml.Style 'ss:ID' => 'ShortDate' do
52
51
  xml.NumberFormat 'ss:Format' => 'Short Date'
53
52
  end
@@ -10,7 +10,7 @@ xml.Workbook(
10
10
  'xmlns:ss' => 'urn:schemas-microsoft-com:office:spreadsheet',
11
11
  'xmlns:html' => 'http://www.w3.org/TR/REC-html40'
12
12
  ) do
13
- xml << render(partial: '/layouts/excel_styles')
13
+ xml << render(partial: '/drilldown/excel_styles')
14
14
 
15
15
  xml.Worksheet 'ss:Name' => 'Drilldown' do
16
16
  xml.Table do
@@ -26,17 +26,17 @@ xml.Workbook(
26
26
  end
27
27
 
28
28
  xml.Row 'ss:StyleID' => 'Heading' do
29
- @transaction_fields.each do |field|
29
+ @search.fields.each do |field|
30
30
  if field == 'time'
31
31
  xml.Cell do
32
- xml.Data (l :short_date).to_s, 'ss:Type' => 'String'
32
+ xml.Data (t :short_date).to_s, 'ss:Type' => 'String'
33
33
  end
34
34
  xml.Cell do
35
- xml.Data (l :time).to_s, 'ss:Type' => 'String'
35
+ xml.Data (t :time).to_s, 'ss:Type' => 'String'
36
36
  end
37
37
  else
38
38
  xml.Cell do
39
- xml.Data (l field).to_s, 'ss:Type' => 'String'
39
+ xml.Data (t field).to_s, 'ss:Type' => 'String'
40
40
  end
41
41
  end
42
42
  end
@@ -44,7 +44,7 @@ xml.Workbook(
44
44
 
45
45
  @records.each do |transaction|
46
46
  xml.Row do
47
- @transaction_fields.each do |field|
47
+ @search.fields.each do |field|
48
48
  field_map = controller.c_fields[field.to_sym]
49
49
  if field == 'time'
50
50
  xml.Cell 'ss:StyleID' => 'DateOnlyFormat' do
@@ -54,7 +54,8 @@ xml.Workbook(
54
54
  xml.Data transaction.completed_at.gmtime.xmlschema, 'ss:Type' => 'DateTime'
55
55
  end
56
56
  else
57
- value = field_map[:attr_method] ? field_map[:attr_method].call(transaction) : transaction.send(field)
57
+ attr_method = field_map[:attr_method]
58
+ value = attr_method ? attr_method.call(transaction) : transaction.send(field)
58
59
  xml.Cell field_map[:excel_style] ? { 'ss:StyleID' => field_map[:excel_style] } : {} do
59
60
  xml.Data value, 'ss:Type' => field_map[:excel_type] || 'String'
60
61
  end
@@ -1,6 +1,6 @@
1
- <h1><%=caption%></h2>
2
- <h2><%=subcaption %></h3>
1
+ <h1><%= caption %></h1>
2
+ <h2><%= subcaption %></h2>
3
3
  <br/>
4
4
  <div style="width: 98%; padding: 5px;">
5
- <%=render :partial => '/drilldown/summary_table' %>
5
+ <%= render '/drilldown/summary_table' %>
6
6
  </div>
@@ -1,12 +1,15 @@
1
1
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
3
 
4
4
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
- <%= render 'layouts/headers' %>
6
- <%= stylesheet_link_tag 'drilldown' %>
5
+ <%= stylesheet_link_tag 'application' %>
7
6
  <body>
8
7
  <style type="text/css">
9
- @media print {#print_link {display: none}}
8
+ @media print {
9
+ #print_link {
10
+ display: none
11
+ }
12
+ }
10
13
  </style>
11
14
  <div class="container">
12
15
  <div id="print_link" class="pull-right">
data/config/routes.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  SimpleDrilldown::Engine.routes.draw do
4
+ # No routes, yet.
4
5
  end
@@ -6,6 +6,6 @@ class DrilldownControllerGenerator < Rails::Generators::NamedBase
6
6
  def copy_drilldown_controller_file
7
7
  template 'drilldown_controller.rb.erb', "app/controllers/#{file_name}_drilldown_controller.rb"
8
8
  template 'drilldown_controller_test.rb.erb', "test/controllers/#{file_name}_drilldown_controller_test.rb"
9
- route "draw_drilldown :#{singular_name}_drilldown"
9
+ route "draw_drilldown :#{singular_name}"
10
10
  end
11
11
  end
@@ -36,6 +36,9 @@ module SimpleDrilldown
36
36
  # No default target class found
37
37
  end
38
38
  end
39
+ return unless base.c_target_class.try :paranoid?
40
+
41
+ base.c_base_condition = "#{base.c_target_class.table_name}.deleted_at IS NULL"
39
42
  end
40
43
 
41
44
  def base_condition(base_condition)
@@ -128,7 +131,8 @@ module SimpleDrilldown
128
131
  pretty_name: I18n.t(name, default: :"activerecord.models.#{name}"),
129
132
  queries: queries,
130
133
  reverse: reverse,
131
- select_expression: "COALESCE(#{queries.map { |q| q[:select] }.join(',')})",
134
+ select_expression:
135
+ queries.size == 1 ? queries[0][:select] : "COALESCE(#{queries.map { |q| q[:select] }.join(',')})",
132
136
  row_class: row_class,
133
137
  url_param_name: name.to_s
134
138
  }
@@ -319,6 +323,7 @@ module SimpleDrilldown
319
323
 
320
324
  conditions, @filter_text, filter_includes = self.class.make_conditions(@search.filter)
321
325
  includes += filter_includes
326
+ includes.flatten!
322
327
  includes.keep_if(&:present?).uniq!
323
328
  if @search.order_by_value && @dimensions.size <= 1
324
329
  order = case @search.select_value
@@ -385,21 +390,24 @@ module SimpleDrilldown
385
390
 
386
391
  def html_export
387
392
  index(false)
388
- render template: '/drilldown/html_export', layout: 'print'
393
+ render template: '/drilldown/html_export', layout: '../drilldown/print'
389
394
  end
390
395
 
391
396
  def excel_export
392
397
  index(false)
393
398
  set_excel_headers
394
- render template: '/drilldown/excel_export', layout: false
399
+ if params.dig(:search, :list) == '1'
400
+ @records = get_records(@result)
401
+ render template: '/drilldown/excel_export_records', layout: false
402
+ else
403
+ render template: '/drilldown/excel_export', layout: false
404
+ end
395
405
  end
396
406
 
397
407
  def excel_export_records
408
+ params[:search] ||= {}
398
409
  params[:search][:list] = '1'
399
- index(false)
400
- @records = get_records(@result)
401
- set_excel_headers
402
- render template: '/drilldown/excel_export_records', layout: false
410
+ excel_export
403
411
  end
404
412
 
405
413
  private
@@ -3,6 +3,10 @@
3
3
  module SimpleDrilldown
4
4
  # View helper for SimpleDrilldown
5
5
  module Helper
6
+ # FIXME(uwe): Should not be necessary: https://github.com/rails/rails/issues/41038
7
+ include Rails.application.routes.url_helpers
8
+ # EMXIF
9
+
6
10
  def value_label(dimension_index, value)
7
11
  dimension = @dimensions[dimension_index]
8
12
  return nil if dimension.nil?
@@ -3,12 +3,13 @@
3
3
  module SimpleDrilldown
4
4
  # Routing helper methods
5
5
  module Routing
6
- def draw_drilldown(path, controller = path)
6
+ def draw_drilldown(path, controller = nil)
7
+ path = "#{path}_drilldown" unless /_drilldown$/.match?(path)
8
+ controller ||= path
7
9
  get "#{path}(.:format)" => "#{controller}#index", as: path
8
- scope path do
9
- %i[choices excel_export html_export index].each do |action|
10
- get "#{action}(/:id)(.:format)", controller: controller, action: action
11
- end
10
+ scope path, controller: controller, as: path do
11
+ %i[excel_export excel_export_records html_export].each { |action| get action }
12
+ get 'choices/:dimension_name', action: :choices, as: :choices
12
13
  end
13
14
  end
14
15
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleDrilldown
2
- VERSION = '0.6.8'
2
+ VERSION = '0.7.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.6.8
4
+ version: 0.7.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: 2020-09-25 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.80'
53
+ version: '1.1'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.80'
60
+ version: '1.1'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: sqlite3
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -113,7 +113,7 @@ files:
113
113
  - app/views/drilldown/data_2.builder
114
114
  - app/views/drilldown/data_3.builder
115
115
  - app/views/drilldown/excel_export.builder
116
- - app/views/drilldown/excel_export_transactions.builder
116
+ - app/views/drilldown/excel_export_records.builder
117
117
  - app/views/drilldown/html_export.html.erb
118
118
  - app/views/drilldown/index.html.erb
119
119
  - app/views/drilldown/print.html.erb
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.1.2
156
+ rubygems_version: 3.2.3
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Simple data warehouse and drilldown.