active_scaffold_export 3.10.0 → 3.11.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: '028314bd560c02524ab75e89fa886e1e6aa4e547fc2d897586ce8f512a33abb5'
4
- data.tar.gz: 34b28d3afa5cc307d9728f59ea4a1b9e69ecd4fa66d27f3529d2e81da47801bc
3
+ metadata.gz: 2d5312e7623d39bea07a170c97a09ded3d0b8e4098be2f0a6a5f25a89a0e8504
4
+ data.tar.gz: 0a97a570324341b12eba83242da5f13bd98b93c0d84bae2c5bb07616fc981ce1
5
5
  SHA512:
6
- metadata.gz: f73011a115e19299e76b45eebc6abaa485ac3a86e57db94c3c96902ebe8fbc828f1e506de388a44791a671fc9018c88b6736f904bfe462804734ddff002b1689
7
- data.tar.gz: d2f05275d642ea686552a01f29484ad108e2e16e18c0e1bb0e7ce66b33b3aee44adb2f2cf4c69d3f56d0b3436cb544ffdb67436cc3d967cf40f91095eda3f3ab
6
+ metadata.gz: 07610bac0c7d18ff5ce0875cc4c0eac12e65a8283f49bc3842ac39bfc397de99d932279bbe331f3114896bf9e6f675cd241f9d0788ce914e46c18a938ebaf1ff
7
+ data.tar.gz: 53d34e052c132b57229c27daff2af74f3ba8dcb1a522097fff9dc63c681b12372baaf155fadf65e3b483cf039a26f3a679324a34d7fa723fda5dcee70e8c8cc7
data/README.md CHANGED
@@ -39,6 +39,11 @@ conf.export.force_quotes = "true"
39
39
  ```
40
40
  And enjoy happy exporting :)
41
41
 
42
+ ### Configuring
43
+
44
+ There are other options for the action export, explained in the wiki [Export Configuration](https://github.com/activescaffold/active_scaffold_export/wiki/Export-Configuration),
45
+ and it's possible to define [helper overrides](https://github.com/activescaffold/active_scaffold_export/wiki/Helper-Overrides) to change the exported value.
46
+
42
47
  ### Security
43
48
  It's controlled the same way as Active Scaffold. The extra actions added are:
44
49
  * **:show_export** for the options form
@@ -56,8 +61,11 @@ active_scaffold:
56
61
  ```
57
62
 
58
63
  ### XLSX support
59
- This support depends on caxlsx_rails and caxlsx of course.
60
- header styling override will be added soon.
64
+ This support depends on caxlsx_rails and caxlsx of course, and supports changing the style of cells and headers, as explained
65
+ in the wiki [Cell Format Options](https://github.com/activescaffold/active_scaffold_export/wiki/Cell-Format-Options). Also,
66
+ the [helper overrides](https://github.com/activescaffold/active_scaffold_export/wiki/Helper-Overrides#column-helper) may return
67
+ a hash with format options besides the value.
68
+
61
69
  NOTE: There's NO streaming support for xlsx format. Only CSV. So if your data is huge, set default_file_format to 'csv' instead.
62
70
  Streaming in xlsx will never be supported since the entire file needs to be serialized and zipped to be a valid OOXML file.
63
71
  So, rather than streaming, background jobs will be the most likely future approach.
@@ -71,5 +79,11 @@ def worksheet_name(options = {})
71
79
  end
72
80
  ```
73
81
 
82
+ ### Grouped search
83
+
84
+ Export supports grouped search from field_search action. When grouped search is used, instead of exporting the normal columns, only the listed columns will be exported, the ones in `conf.list.columns` with calculation, or the ones in `conf.field_search.grouped_columns`. In this case, the normal helper overrides won't be used, and will use `grouped_export_column` suffix instead.
85
+
86
+ ## Contact
87
+
74
88
  For contact, help, support, comments, please use Active Scaffold official mailing list activescaffold@googlegroups.com
75
89
 
@@ -12,7 +12,7 @@
12
12
  csv << fcsv_options[:headers] unless params[:skip_header]
13
13
  @records.each do |record|
14
14
  csv << @export_columns.collect { |column|
15
- get_export_column_value(record, column, :csv).first
15
+ get_export_column_value(record, column, :csv)&.first
16
16
  }
17
17
  end
18
18
  end
@@ -1,4 +1,3 @@
1
- <% export_config = active_scaffold_config.export %>
2
1
  <h3><%=as_(:columns_for_export)%></h3>
3
2
  <%# TODO: use JS asset instead of inline JS %>
4
3
  <%= link_to as_(:select_all), '#', onclick: 'jQuery(".columnCheckbox").prop("checked", true); return false', class: 'active-scaffold-footer' %>
@@ -8,7 +7,7 @@
8
7
  <% export_columns_names(true).each_column do |column| -%>
9
8
  <div class="column checkbox-wrapper">
10
9
  <label>
11
- <%= check_box_tag("export_columns[#{column.name}]", 1, !export_config.default_deselected_columns.include?(column.name), :class => 'columnCheckbox') %>
10
+ <%= check_box_tag("export_columns[#{column.name}]", 1, !active_scaffold_config.export.default_deselected_columns.include?(column.name), :class => 'columnCheckbox') %>
12
11
  <%= column_heading_label(column) %>
13
12
  </label>
14
13
  </div>
@@ -18,30 +17,17 @@
18
17
  <div class="separator"></div>
19
18
  <h3><%=as_(:options)%></h3>
20
19
  <div class="options checkbox-list">
21
- <div class="option checkbox-wrapper">
22
- <%= content_tag(:label, check_box_tag('skip_header', 1, export_config.default_skip_header) + " #{as_(:omit_header)}".html_safe) %>
23
- </div>
24
- <div class="option checkbox-wrapper">
25
- <%= content_tag(:label, text_field_tag('delimiter', export_config.default_delimiter, :size => 1, :maxlength => 1) + " #{as_(:delimiter)}".html_safe) %>
26
- </div>
27
- <div class="separator"></div>
28
- <% if export_config.allow_full_download %>
29
- <div class="option checkbox-wrapper">
30
- <%= content_tag(:label, radio_button_tag('full_download', false, !export_config.default_full_download) + " #{as_(:this_page)}".html_safe) %>
31
- </div>
32
- <div class="option checkbox-wrapper">
33
- <%= content_tag(:label, radio_button_tag('full_download', true, export_config.default_full_download) + " #{as_(:all_pages)}".html_safe) %>
34
- </div>
35
- <div class="separator"></div>
36
- <% end %>
37
- <% if export_config.formats.many? %>
38
- <% export_config.formats.each do |format| %>
39
- <div class="option checkbox-wrapper">
40
- <%= content_tag(:label, safe_join([radio_button_tag('format', format, export_config.default_file_format.to_sym == format), format.upcase], ' ')) %>
41
- </div>
42
- <% end %>
43
- <% else %>
44
- <%= hidden_field_tag 'format', export_config.formats[0] %>
20
+ <% export_options.each do |row_optionss| %>
21
+ <% row_optionss.each do |(option, label)| %>
22
+ <div class="option checkbox-wrapper">
23
+ <% if label %>
24
+ <%= content_tag(:label, safe_join([option, label.is_a?(Symbol) ? as_(label) : label], ' ')) %>
25
+ <% else %>
26
+ <%= option %>
27
+ <% end %>
28
+ </div>
29
+ <% end %>
30
+ <div class="separator"></div>
45
31
  <% end %>
46
32
  &nbsp;
47
33
  </div>
@@ -113,7 +113,10 @@ module ActiveScaffold::Actions
113
113
 
114
114
  def export_columns
115
115
  return @export_columns if defined? @export_columns
116
- @export_columns = export_columns_names.reject { |col| params[:export_columns][col.to_sym].nil? }
116
+ @export_columns = export_columns_names.reject do |col|
117
+ params[:export_columns][col.to_sym].nil? ||
118
+ !active_scaffold_config.model.authorized_for?(crud_type: :read, column: col.to_sym)
119
+ end
117
120
  sorting = active_scaffold_config.list.user.sorting || active_scaffold_config.list.sorting
118
121
  sorting_columns = sorting.reject { |col, _| @export_columns.include?(col.name) }.map(&:first)
119
122
  @export_columns.map! { |col| active_scaffold_config.columns[col] }
@@ -10,6 +10,7 @@ module ActiveScaffold
10
10
  # format_singular_association_export_column(association_record)
11
11
  # format_plural_association_export_column(association_records)
12
12
  def get_export_column_value(record, column, format)
13
+ return unless record.authorized_for?(crud_type: :read, column: column.name)
13
14
  if (method = export_column_override(column))
14
15
  value, options = send(method, record, format)
15
16
  [value, options || export_column_style(column, format)]
@@ -37,7 +38,7 @@ module ActiveScaffold
37
38
 
38
39
  def export_column_style(column, format)
39
40
  style = column.export_options&.dig(format)
40
- format = :xlsx && style.frozen? ? style.deep_dup : style
41
+ format == :xlsx && style.frozen? ? style.deep_dup : style
41
42
  end
42
43
 
43
44
  def export_column_override(column)
@@ -93,6 +94,28 @@ module ActiveScaffold
93
94
  end
94
95
  end
95
96
 
97
+ def export_options
98
+ export_config = active_scaffold_config.export
99
+ rows = []
100
+ rows << [
101
+ [check_box_tag('skip_header', 1, export_config.default_skip_header), :omit_header],
102
+ [text_field_tag('delimiter', export_config.default_delimiter, :size => 1, :maxlength => 1), :delimiter]
103
+ ]
104
+ if export_config.allow_full_download
105
+ rows << [
106
+ [radio_button_tag('full_download', false, !export_config.default_full_download), :this_page],
107
+ [radio_button_tag('full_download', true, export_config.default_full_download), :all_pages]
108
+ ]
109
+ end
110
+ if export_config.formats.many?
111
+ rows << export_config.formats.map do |format|
112
+ [radio_button_tag('format', format, export_config.default_file_format.to_sym == format), format.upcase.to_s]
113
+ end
114
+ else
115
+ rows << [hidden_field_tag('format', export_config.formats[0])]
116
+ end
117
+ end
118
+
96
119
  end
97
120
  end
98
121
  end
@@ -1,7 +1,7 @@
1
1
  module ActiveScaffoldExport
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 10
4
+ MINOR = 11
5
5
  PATCH = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
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.10.0
4
+ version: 3.11.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-05-15 00:00:00.000000000 Z
13
+ date: 2025-09-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: active_scaffold