active_scaffold_export 3.9.3 → 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: 17a2384e4ea87f37820137c5a5b4d77263e1c897b286229ed4c1c3da0ee1a5cd
4
- data.tar.gz: 2b37e2b9b189725d3c3735d782d262a9d3df8e8f816a83dfe36a65545147da07
3
+ metadata.gz: '028314bd560c02524ab75e89fa886e1e6aa4e547fc2d897586ce8f512a33abb5'
4
+ data.tar.gz: 34b28d3afa5cc307d9728f59ea4a1b9e69ecd4fa66d27f3529d2e81da47801bc
5
5
  SHA512:
6
- metadata.gz: aea5b9dd175581c8d730271cdb0067d7c7721c271ab57593a2c92de7bef9365356c923af7834d43b6d3adbc49b53135f79d5c22121223a560e1e59a1685036ea
7
- data.tar.gz: 07f93b89c04d65fcfbc5630a1bf932e0aab23e0772b90569d3cc495aa19b1304b23fdeb87394a73822080243ee5cdca285d70fe76554b108168211385526a144
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,14 +34,14 @@ 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
43
- @find_options = find_options_for_export
44
+ @page = find_page(find_options_for_export)
44
45
 
45
46
  # this is required if you want this to work with IE
46
47
  if request.env['HTTP_USER_AGENT'] =~ /msie/i
@@ -60,7 +61,7 @@ module ActiveScaffold::Actions
60
61
  response.headers['last-modified'] = '0'
61
62
  # start streaming output
62
63
  self.response_body = Enumerator.new do |y|
63
- find_items_for_export(@find_options) do |records|
64
+ find_items_for_export do |records|
64
65
  @records = records
65
66
  str = render_to_string :partial => 'export', :layout => false, :formats => [:csv]
66
67
  y << str
@@ -80,7 +81,7 @@ module ActiveScaffold::Actions
80
81
  styles.map! { |style| pkg.workbook.styles.add_style style if style }
81
82
  sheet.add_row(@export_columns.collect { |column| view_context.format_export_column_header_name(column) }, style: styles, widths: widths)
82
83
  end
83
- find_items_for_export(@find_options) do |records|
84
+ find_items_for_export do |records|
84
85
  records.each do |record|
85
86
  row = []
86
87
  styles = []
@@ -112,13 +113,23 @@ module ActiveScaffold::Actions
112
113
 
113
114
  def export_columns
114
115
  return @export_columns if defined? @export_columns
115
- @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? }
116
117
  sorting = active_scaffold_config.list.user.sorting || active_scaffold_config.list.sorting
117
118
  sorting_columns = sorting.reject { |col, _| @export_columns.include?(col.name) }.map(&:first)
118
119
  @export_columns.map! { |col| active_scaffold_config.columns[col] }
119
120
  @export_columns += sorting_columns
120
121
  end
121
122
 
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
+
122
133
  def find_options_for_export
123
134
  find_options = {sorting: active_scaffold_config.list.sorting, pagination: true}
124
135
  do_search rescue nil
@@ -136,13 +147,13 @@ module ActiveScaffold::Actions
136
147
  end
137
148
 
138
149
  # The actual algorithm to do the export
139
- def find_items_for_export(find_options, &block)
150
+ def find_items_for_export(&block)
140
151
  if params[:full_download] == 'true'
141
- find_page(find_options).pager.each do |page|
152
+ @page.pager.each do |page|
142
153
  yield page.items
143
154
  end
144
155
  else
145
- yield find_page(find_options).items
156
+ yield @page.items
146
157
  end
147
158
  end
148
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 = 3
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.3
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-03-12 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