active_scaffold_export 3.9.2 → 3.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d4efa340b028988b72b01057c337971ffa7afb17c6f84865992f9fc7f1be99a0
4
- data.tar.gz: 2bd4bd6c5c5339cd8579127e9bbd39707adff96132ad61a4baf3ddba9f03745a
3
+ metadata.gz: '028314bd560c02524ab75e89fa886e1e6aa4e547fc2d897586ce8f512a33abb5'
4
+ data.tar.gz: 34b28d3afa5cc307d9728f59ea4a1b9e69ecd4fa66d27f3529d2e81da47801bc
5
5
  SHA512:
6
- metadata.gz: 8f2b3155b131b1affb596f9002abc30252857a6ebc1454c73fcf8bf09ba330e246f6f158adb9357a9ec398bfd55d03489f8b2f990fa4b1e6b941404b4e1f854b
7
- data.tar.gz: 644222fc4d6930a4d8f48f9b06365cc2be3098948e377335cc4b6ee3081208e9d94081220ba7ed3d15ac2c6d633f3313e3f3c4b5dbe86f3b7515510bf61bc00c
6
+ metadata.gz: f73011a115e19299e76b45eebc6abaa485ac3a86e57db94c3c96902ebe8fbc828f1e506de388a44791a671fc9018c88b6736f904bfe462804734ddff002b1689
7
+ data.tar.gz: d2f05275d642ea686552a01f29484ad108e2e16e18c0e1bb0e7ce66b33b3aee44adb2f2cf4c69d3f56d0b3436cb544ffdb67436cc3d967cf40f91095eda3f3ab
@@ -5,9 +5,12 @@
5
5
  |
6
6
  <%= link_to as_(:select_none), '#', onclick: 'jQuery(".columnCheckbox").prop("checked", false); return false', class: 'active-scaffold-footer' %>
7
7
  <div class="columns checkbox-list">
8
- <% export_config.columns.each_column do |column| -%>
8
+ <% export_columns_names(true).each_column do |column| -%>
9
9
  <div class="column checkbox-wrapper">
10
- <%= content_tag(:label, check_box_tag("export_columns[#{column.name}]", 1, !export_config.default_deselected_columns.include?(column.name), :class => 'columnCheckbox') + "&nbsp;#{column.label}".html_safe) %>
10
+ <label>
11
+ <%= check_box_tag("export_columns[#{column.name}]", 1, !export_config.default_deselected_columns.include?(column.name), :class => 'columnCheckbox') %>
12
+ <%= column_heading_label(column) %>
13
+ </label>
11
14
  </div>
12
15
  <% end -%>
13
16
  &nbsp;
@@ -3,6 +3,7 @@ module ActiveScaffold::Actions
3
3
  def self.included(base)
4
4
  base.before_action :export_authorized?, :only => [:export]
5
5
  base.before_action :show_export_authorized?, :only => [:show_export]
6
+ base.helper_method :export_columns_names
6
7
  end
7
8
 
8
9
  # display the customization form or skip directly to export
@@ -23,7 +24,7 @@ module ActiveScaffold::Actions
23
24
  export_config = active_scaffold_config.export
24
25
  if params[:export_columns].nil?
25
26
  export_columns = {}
26
- export_config.columns.each { |col| export_columns[col.to_sym] = 1 }
27
+ export_columns_names.each { |col| export_columns[col.to_sym] = 1 }
27
28
  options = {
28
29
  :export_columns => export_columns,
29
30
  :full_download => export_config.default_full_download.to_s,
@@ -33,21 +34,22 @@ module ActiveScaffold::Actions
33
34
  params.merge!(options)
34
35
  end
35
36
 
36
- set_includes_for_columns(:export)
37
+ set_includes_for_columns(:export) # will call export_columns which will set @export_columns
37
38
  @export_config = export_config
38
39
  # Make sure active_scaffold's find_page is dealing with the same list of
39
40
  # columns. Prevents an invalid SQL query when exporting after filtering
40
41
  # with field_search against a relation column, and that relation column is
41
42
  # not included in the set of export columns.
42
43
  @list_columns = @export_columns
44
+ @page = find_page(find_options_for_export)
43
45
 
44
46
  # this is required if you want this to work with IE
45
47
  if request.env['HTTP_USER_AGENT'] =~ /msie/i
46
- response.headers['Pragma'] = "public"
47
- response.headers['Cache-Control'] = "no-cache, must-revalidate, post-check=0, pre-check=0"
48
- response.headers['Expires'] = "0"
48
+ response.headers['pragma'] = "public"
49
+ response.headers['cache-control'] = "no-cache, must-revalidate, post-check=0, pre-check=0"
50
+ response.headers['expires'] = "0"
49
51
  end
50
- response.headers['Content-Disposition'] = "attachment; filename=#{export_file_name}"
52
+ response.headers['content-disposition'] = "attachment; filename=#{export_file_name}"
51
53
 
52
54
  respond_to_action(:export)
53
55
  end
@@ -55,7 +57,8 @@ module ActiveScaffold::Actions
55
57
  protected
56
58
 
57
59
  def export_respond_to_csv
58
- response.headers['Content-type'] = Mime[:csv]
60
+ response.headers['content-type'] = Mime[:csv]
61
+ response.headers['last-modified'] = '0'
59
62
  # start streaming output
60
63
  self.response_body = Enumerator.new do |y|
61
64
  find_items_for_export do |records|
@@ -68,7 +71,8 @@ module ActiveScaffold::Actions
68
71
  end
69
72
 
70
73
  def export_respond_to_xlsx
71
- response.headers['Content-type'] = Mime[:xlsx]
74
+ response.headers['content-type'] = Mime[:xlsx]
75
+ response.headers['last-modified'] = '0'
72
76
  pkg = Axlsx::Package.new
73
77
  pkg.workbook.add_worksheet(name: worksheet_name) do |sheet|
74
78
  styles = @export_columns.collect { |column| view_context.export_column_header_style(column, :xlsx) }
@@ -109,39 +113,47 @@ module ActiveScaffold::Actions
109
113
 
110
114
  def export_columns
111
115
  return @export_columns if defined? @export_columns
112
- @export_columns = active_scaffold_config.export.columns.reject { |col| params[:export_columns][col.to_sym].nil? }
116
+ @export_columns = export_columns_names.reject { |col| params[:export_columns][col.to_sym].nil? }
113
117
  sorting = active_scaffold_config.list.user.sorting || active_scaffold_config.list.sorting
114
118
  sorting_columns = sorting.reject { |col, _| @export_columns.include?(col.name) }.map(&:first)
115
119
  @export_columns.map! { |col| active_scaffold_config.columns[col] }
116
120
  @export_columns += sorting_columns
117
121
  end
118
122
 
119
- # The actual algorithm to do the export
120
- def find_items_for_export(&block)
121
- find_options = { :sorting =>
122
- active_scaffold_config.list.user.sorting.nil? ?
123
- active_scaffold_config.list.sorting : active_scaffold_config.list.user.sorting,
124
- :pagination => true
125
- }
123
+ def export_columns_names(action_columns = false)
124
+ if grouped_search?
125
+ list_columns_names.then do |cols|
126
+ action_columns ? active_scaffold_config.build_action_columns(:export, cols) : cols
127
+ end
128
+ else
129
+ active_scaffold_config.export.columns
130
+ end
131
+ end
132
+
133
+ def find_options_for_export
134
+ find_options = {sorting: active_scaffold_config.list.sorting, pagination: true}
126
135
  do_search rescue nil
127
- params[:segment_id] = session[:segment_id]
128
- do_segment_search rescue nil
129
136
 
130
137
  if params[:full_download] == 'true'
131
- find_options.merge!({
132
- :per_page => 3000,
133
- :page => 1
134
- })
135
- find_page(find_options).pager.each do |page|
138
+ find_options.merge!(per_page: 3000, page: 1)
139
+ else
140
+ find_options.merge!(
141
+ pagination: active_scaffold_config.list.pagination,
142
+ per_page: active_scaffold_config.list.user.per_page,
143
+ page: active_scaffold_config.list.user.page
144
+ )
145
+ end
146
+ find_options
147
+ end
148
+
149
+ # The actual algorithm to do the export
150
+ def find_items_for_export(&block)
151
+ if params[:full_download] == 'true'
152
+ @page.pager.each do |page|
136
153
  yield page.items
137
154
  end
138
155
  else
139
- find_options.merge!({
140
- :pagination => active_scaffold_config.list.pagination,
141
- :per_page => active_scaffold_config.list.user.per_page,
142
- :page => active_scaffold_config.list.user.page
143
- })
144
- yield find_page(find_options).items
156
+ yield @page.items
145
157
  end
146
158
  end
147
159
 
@@ -16,6 +16,8 @@ module ActiveScaffold
16
16
  elsif column.list_ui && (method = override_export_ui(column.list_ui))
17
17
  value, options = send(method, record, column, format, ui_options: column.list_ui_options || column.options)
18
18
  [value, options || export_column_style(column, format)]
19
+ elsif grouped_search? && column == search_group_column && search_group_function
20
+ [format_grouped_search_column(record[column.name], column.options), export_column_style(column, format)]
19
21
  else
20
22
  raw_value = record.send(column.name)
21
23
 
@@ -39,7 +41,7 @@ module ActiveScaffold
39
41
  end
40
42
 
41
43
  def export_column_override(column)
42
- override_helper column, 'export_column'
44
+ override_helper column, grouped_search? ? 'grouped_export_column' : 'export_column'
43
45
  end
44
46
 
45
47
  # the naming convention for overriding column types with helpers
@@ -81,7 +83,7 @@ module ActiveScaffold
81
83
  ## This helper can be overridden to change the name of the headers
82
84
  # For instance, you might want column.name.to_s.humanize
83
85
  def format_export_column_header_name(column)
84
- column.label
86
+ column_heading_label column
85
87
  end
86
88
 
87
89
  ## This helper can be overridden to change the style of the headers
@@ -1,8 +1,8 @@
1
1
  module ActiveScaffoldExport
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 9
5
- PATCH = 2
4
+ MINOR = 10
5
+ PATCH = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.2
4
+ version: 3.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volker Hochstein
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2025-02-23 00:00:00.000000000 Z
13
+ date: 2025-05-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: active_scaffold