active_scaffold_export 3.9.1 → 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: 270c47817326448305acea738088f43e9fc7bd0b1ae0283915feb8fde4b8a478
4
- data.tar.gz: b23ae05c9749d8708568b15eb2b4a44f02f59ecd23df0a57a76e46481300655e
3
+ metadata.gz: 17a2384e4ea87f37820137c5a5b4d77263e1c897b286229ed4c1c3da0ee1a5cd
4
+ data.tar.gz: 2b37e2b9b189725d3c3735d782d262a9d3df8e8f816a83dfe36a65545147da07
5
5
  SHA512:
6
- metadata.gz: 2b6f90a0ed3d81463a12d3b62d35c65ac03cc09d0d0754f666441948f9e259f149778660213948d691f200f235192ad16f01859b5c0b5f9d557d613864e3f06e
7
- data.tar.gz: 365fc9c8d0ad96bd8f577ec4959dc8fa4b97aa9cf7f16886d96833604b475a3ae38f47c48a7c93cfee0e2e6c9c6fc2d7bf08b37bce635ee32e699c13d45a201e
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
@@ -95,7 +95,7 @@ module ActiveScaffold::Config
95
95
  end
96
96
 
97
97
  def default_deselected_columns
98
- self.default_deselected_columns = ActiveScaffold::DataStructures::Set.new if @default_deselected_columns.nil?
98
+ @default_deselected_columns ||= ActiveScaffold::DataStructures::Set.new unless frozen?
99
99
  @default_deselected_columns
100
100
  end
101
101
 
@@ -104,5 +104,21 @@ module ActiveScaffold::Config
104
104
  def multipart?
105
105
  false
106
106
  end
107
+
108
+ UserSettings.class_eval do
109
+ user_attr :show_form, :allow_full_download, :force_quotes, :default_file_format,
110
+ :default_delimiter, :default_skip_header, :default_file_format
111
+
112
+ def default_deselected_columns=(val)
113
+ @default_deselected_columns = ActiveScaffold::DataStructures::Set.new(*val)
114
+ end
115
+
116
+ def default_deselected_columns
117
+ if @default_deselected_columns.nil? && @conf.default_deselected_columns
118
+ return @conf.default_deselected_columns
119
+ end
120
+ @default_deselected_columns ||= ActiveScaffold::DataStructures::Set.new
121
+ end
122
+ end
107
123
  end
108
124
  end
@@ -2,7 +2,7 @@ module ActiveScaffoldExport
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 9
5
- PATCH = 1
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.1
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