active_scaffold_export 3.9.2 → 3.9.3

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: 17a2384e4ea87f37820137c5a5b4d77263e1c897b286229ed4c1c3da0ee1a5cd
4
+ data.tar.gz: 2b37e2b9b189725d3c3735d782d262a9d3df8e8f816a83dfe36a65545147da07
5
5
  SHA512:
6
- metadata.gz: 8f2b3155b131b1affb596f9002abc30252857a6ebc1454c73fcf8bf09ba330e246f6f158adb9357a9ec398bfd55d03489f8b2f990fa4b1e6b941404b4e1f854b
7
- data.tar.gz: 644222fc4d6930a4d8f48f9b06365cc2be3098948e377335cc4b6ee3081208e9d94081220ba7ed3d15ac2c6d633f3313e3f3c4b5dbe86f3b7515510bf61bc00c
6
+ metadata.gz: aea5b9dd175581c8d730271cdb0067d7c7721c271ab57593a2c92de7bef9365356c923af7834d43b6d3adbc49b53135f79d5c22121223a560e1e59a1685036ea
7
+ data.tar.gz: 07f93b89c04d65fcfbc5630a1bf932e0aab23e0772b90569d3cc495aa19b1304b23fdeb87394a73822080243ee5cdca285d70fe76554b108168211385526a144
@@ -40,14 +40,15 @@ module ActiveScaffold::Actions
40
40
  # with field_search against a relation column, and that relation column is
41
41
  # not included in the set of export columns.
42
42
  @list_columns = @export_columns
43
+ @find_options = find_options_for_export
43
44
 
44
45
  # this is required if you want this to work with IE
45
46
  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"
47
+ response.headers['pragma'] = "public"
48
+ response.headers['cache-control'] = "no-cache, must-revalidate, post-check=0, pre-check=0"
49
+ response.headers['expires'] = "0"
49
50
  end
50
- response.headers['Content-Disposition'] = "attachment; filename=#{export_file_name}"
51
+ response.headers['content-disposition'] = "attachment; filename=#{export_file_name}"
51
52
 
52
53
  respond_to_action(:export)
53
54
  end
@@ -55,10 +56,11 @@ module ActiveScaffold::Actions
55
56
  protected
56
57
 
57
58
  def export_respond_to_csv
58
- response.headers['Content-type'] = Mime[:csv]
59
+ response.headers['content-type'] = Mime[:csv]
60
+ response.headers['last-modified'] = '0'
59
61
  # start streaming output
60
62
  self.response_body = Enumerator.new do |y|
61
- find_items_for_export do |records|
63
+ find_items_for_export(@find_options) do |records|
62
64
  @records = records
63
65
  str = render_to_string :partial => 'export', :layout => false, :formats => [:csv]
64
66
  y << str
@@ -68,7 +70,8 @@ module ActiveScaffold::Actions
68
70
  end
69
71
 
70
72
  def export_respond_to_xlsx
71
- response.headers['Content-type'] = Mime[:xlsx]
73
+ response.headers['content-type'] = Mime[:xlsx]
74
+ response.headers['last-modified'] = '0'
72
75
  pkg = Axlsx::Package.new
73
76
  pkg.workbook.add_worksheet(name: worksheet_name) do |sheet|
74
77
  styles = @export_columns.collect { |column| view_context.export_column_header_style(column, :xlsx) }
@@ -77,7 +80,7 @@ module ActiveScaffold::Actions
77
80
  styles.map! { |style| pkg.workbook.styles.add_style style if style }
78
81
  sheet.add_row(@export_columns.collect { |column| view_context.format_export_column_header_name(column) }, style: styles, widths: widths)
79
82
  end
80
- find_items_for_export do |records|
83
+ find_items_for_export(@find_options) do |records|
81
84
  records.each do |record|
82
85
  row = []
83
86
  styles = []
@@ -116,31 +119,29 @@ module ActiveScaffold::Actions
116
119
  @export_columns += sorting_columns
117
120
  end
118
121
 
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
- }
122
+ def find_options_for_export
123
+ find_options = {sorting: active_scaffold_config.list.sorting, pagination: true}
126
124
  do_search rescue nil
127
- params[:segment_id] = session[:segment_id]
128
- do_segment_search rescue nil
129
125
 
130
126
  if params[:full_download] == 'true'
131
- find_options.merge!({
132
- :per_page => 3000,
133
- :page => 1
134
- })
127
+ find_options.merge!(per_page: 3000, page: 1)
128
+ else
129
+ find_options.merge!(
130
+ pagination: active_scaffold_config.list.pagination,
131
+ per_page: active_scaffold_config.list.user.per_page,
132
+ page: active_scaffold_config.list.user.page
133
+ )
134
+ end
135
+ find_options
136
+ end
137
+
138
+ # The actual algorithm to do the export
139
+ def find_items_for_export(find_options, &block)
140
+ if params[:full_download] == 'true'
135
141
  find_page(find_options).pager.each do |page|
136
142
  yield page.items
137
143
  end
138
144
  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
145
  yield find_page(find_options).items
145
146
  end
146
147
  end
@@ -2,7 +2,7 @@ module ActiveScaffoldExport
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 9
5
- PATCH = 2
5
+ PATCH = 3
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.9.3
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-03-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: active_scaffold