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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '028314bd560c02524ab75e89fa886e1e6aa4e547fc2d897586ce8f512a33abb5'
|
4
|
+
data.tar.gz: 34b28d3afa5cc307d9728f59ea4a1b9e69ecd4fa66d27f3529d2e81da47801bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
<%
|
8
|
+
<% export_columns_names(true).each_column do |column| -%>
|
9
9
|
<div class="column checkbox-wrapper">
|
10
|
-
|
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
|
|
@@ -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
|
-
|
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
|
-
@
|
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
|
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
|
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 =
|
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(
|
150
|
+
def find_items_for_export(&block)
|
140
151
|
if params[:full_download] == 'true'
|
141
|
-
|
152
|
+
@page.pager.each do |page|
|
142
153
|
yield page.items
|
143
154
|
end
|
144
155
|
else
|
145
|
-
yield
|
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
|
86
|
+
column_heading_label column
|
85
87
|
end
|
86
88
|
|
87
89
|
## This helper can be overridden to change the style of the headers
|
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.
|
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-
|
13
|
+
date: 2025-05-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: active_scaffold
|