active_scaffold_export 3.11.2 → 3.12.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 +4 -4
- data/README.md +19 -6
- data/app/assets/stylesheets/active_scaffold_export.css +4 -18
- data/app/views/active_scaffold_overrides/_export_form_body.html.erb +59 -32
- data/config/locales/en.yml +9 -0
- data/config/locales/es.yml +9 -0
- data/lib/active_scaffold/actions/export.rb +11 -6
- data/lib/active_scaffold/config/export.rb +8 -0
- data/lib/active_scaffold/helpers/export_helpers.rb +1 -14
- data/lib/active_scaffold_export/version.rb +2 -2
- data/lib/active_scaffold_export.rb +2 -0
- metadata +7 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 15977d4b6b96c5445460882770d524ff2ca54682df081f8e5fb63337368b4ec4
|
|
4
|
+
data.tar.gz: 2fffe5855089bfd44f6f93dbcc514fe4908c56c3bda8cc06d8a11bf890ff7f00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e328a1cd507d40e1bf98f6d6f90d868028753b2848d0de380c101140848ae78383f379b6accf9a07aaa78c331e16dd916f7ee46c983d917995566ea027ecdbd0
|
|
7
|
+
data.tar.gz: 8d782d92121c67022a7393ab9bae6a7d59040e2ded06674df98123159c7621beecf76b677f5cad151a8caa64ae8dc2413e2245860ff1aa7cc4919bef58771a3c
|
data/README.md
CHANGED
|
@@ -21,11 +21,9 @@ conf.export.default_file_format = 'csv' # or 'xlsx'
|
|
|
21
21
|
|
|
22
22
|
Read important notes at the bottom about xlsx.
|
|
23
23
|
|
|
24
|
-
Remember to bundle install.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*= require active_scaffold_export
|
|
28
|
-
```
|
|
24
|
+
Remember to run `bundle install`. ActiveScaffold automatically includes the plugin stylesheet; no entry in `application.css` is needed.
|
|
25
|
+
|
|
26
|
+
ActiveScaffold Export 3.12 requires ActiveScaffold 4.4 or newer.
|
|
29
27
|
|
|
30
28
|
Now let's add it to controller, inside active_scaffold config block:
|
|
31
29
|
```ruby
|
|
@@ -36,9 +34,25 @@ conf.export.columns = %w(name last_name phone address)
|
|
|
36
34
|
conf.export.default_deselected_columns = %w(phone address)
|
|
37
35
|
conf.export.default_delimiter = ";"
|
|
38
36
|
conf.export.force_quotes = "true"
|
|
37
|
+
# allow users to drag selected columns into export order
|
|
38
|
+
conf.export.draggable = true
|
|
39
39
|
```
|
|
40
40
|
And enjoy happy exporting :)
|
|
41
41
|
|
|
42
|
+
### UI adapter support
|
|
43
|
+
|
|
44
|
+
The export form uses ActiveScaffold 4.4's standard form elements (`fields_container`, `form_element`, and `form_attribute`) and adds two plugin-specific elements:
|
|
45
|
+
|
|
46
|
+
* `export_option` wraps one export option.
|
|
47
|
+
* `export_option_row` groups related options.
|
|
48
|
+
|
|
49
|
+
For example, an adapter can change their classes without overriding the export partial:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
ActiveScaffold.add_element_attributes :export_option, class: 'form-check'
|
|
53
|
+
ActiveScaffold.add_element_attributes :export_option_row, class: 'd-flex gap-3'
|
|
54
|
+
```
|
|
55
|
+
|
|
42
56
|
### Configuring
|
|
43
57
|
|
|
44
58
|
There are other options for the action export, explained in the wiki [Export Configuration](https://github.com/activescaffold/active_scaffold_export/wiki/Export-Configuration),
|
|
@@ -86,4 +100,3 @@ Export supports grouped search from field_search action. When grouped search is
|
|
|
86
100
|
## Contact
|
|
87
101
|
|
|
88
102
|
For contact, help, support, comments, please use Active Scaffold official mailing list activescaffold@googlegroups.com
|
|
89
|
-
|
|
@@ -4,25 +4,11 @@
|
|
|
4
4
|
background-repeat: no-repeat;
|
|
5
5
|
padding-left: 19px;
|
|
6
6
|
}
|
|
7
|
-
.active-scaffold
|
|
8
|
-
|
|
7
|
+
.active-scaffold .show_export-view .export-option-row {
|
|
8
|
+
display: flex;
|
|
9
|
+
gap: 1em;
|
|
9
10
|
}
|
|
10
|
-
.active-scaffold
|
|
11
|
-
clear: both;
|
|
12
|
-
padding: .5em;
|
|
13
|
-
}
|
|
14
|
-
.active-scaffold div.show_export-view div.options div.separator {
|
|
15
|
-
padding: 0;
|
|
16
|
-
}
|
|
17
|
-
.active-scaffold div.show_export-view div.options div.checkbox-wrapper {
|
|
18
|
-
margin-bottom: .5em;
|
|
19
|
-
}
|
|
20
|
-
.active-scaffold div.show_export-view div div.checkbox-wrapper {
|
|
21
|
-
min-width: 20%;
|
|
22
|
-
margin-bottom: .25em;
|
|
23
|
-
float: left;
|
|
24
|
-
}
|
|
25
|
-
.active-scaffold div.show_export-view label #delimiter {
|
|
11
|
+
.active-scaffold .show_export-view label [name=delimiter] {
|
|
26
12
|
font-family: monospace;
|
|
27
13
|
}
|
|
28
14
|
|
|
@@ -1,34 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<%=
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<%
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
1
|
+
<% export_config = active_scaffold_config.export %>
|
|
2
|
+
<%= as_element :fields_container, class: 'form' do %>
|
|
3
|
+
<%= as_element :form_element, class: 'form-element' do %>
|
|
4
|
+
<%
|
|
5
|
+
columns = export_columns_names(true).visible_columns
|
|
6
|
+
selected_columns = columns.map(&:name).reject { |name| export_config.default_deselected_columns.include?(name) }
|
|
7
|
+
content = active_scaffold_checkbox_list(
|
|
8
|
+
nil,
|
|
9
|
+
columns.map { |column| [column_heading_label(column), column.name] },
|
|
10
|
+
selected_columns,
|
|
11
|
+
{
|
|
12
|
+
name: 'export_columns',
|
|
13
|
+
id: "#{element_form_id(action: :export)}-columns",
|
|
14
|
+
class: 'columns'
|
|
15
|
+
},
|
|
16
|
+
ui_options: {draggable_lists: export_config.draggable, item_options: {class: 'sortable'}}
|
|
17
|
+
)
|
|
18
|
+
%>
|
|
19
|
+
<%= form_attribute_html(nil, as_(:columns_for_export), content, nil, {}) %>
|
|
20
|
+
<% end %>
|
|
21
|
+
|
|
22
|
+
<%= as_element :form_element, class: 'form-element' do %>
|
|
23
|
+
<%
|
|
24
|
+
content = export_options.map do |row_options|
|
|
25
|
+
row_html = row_options.map do |(option, label)|
|
|
26
|
+
as_element(:export_option) do
|
|
27
|
+
label ? content_tag(:label, safe_join([option, label.is_a?(Symbol) ? as_(label) : label], ' ')) : option
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
as_element :export_option_row, safe_join(row_html)
|
|
31
|
+
end
|
|
32
|
+
%>
|
|
33
|
+
<%= form_attribute_html(nil, as_(:export_options), safe_join(content), nil, {}) %>
|
|
34
|
+
<% end %>
|
|
35
|
+
|
|
36
|
+
<% if export_config.allow_full_download %>
|
|
37
|
+
<%= as_element :form_element, class: 'form-element' do %>
|
|
38
|
+
<%
|
|
39
|
+
content = [
|
|
40
|
+
[radio_button_tag('full_download', false, !export_config.default_full_download), as_(:this_page)],
|
|
41
|
+
[radio_button_tag('full_download', true, export_config.default_full_download), as_(:all_pages)]
|
|
42
|
+
].map { |option| content_tag(:label, safe_join(option, ' ')) }
|
|
43
|
+
%>
|
|
44
|
+
<%= form_attribute_html(nil, as_(:export_pages), safe_join(content), nil, {}) %>
|
|
45
|
+
<% end %>
|
|
46
|
+
<% end %>
|
|
47
|
+
|
|
48
|
+
<% if export_config.formats.many? %>
|
|
49
|
+
<%= as_element :form_element, class: 'form-element' do %>
|
|
50
|
+
<%
|
|
51
|
+
content = export_config.formats.map do |format|
|
|
52
|
+
radio = radio_button_tag('format', format, export_config.default_file_format.to_sym == format)
|
|
53
|
+
content_tag(:label, safe_join([radio, format.upcase.to_s], ' '))
|
|
54
|
+
end
|
|
55
|
+
%>
|
|
56
|
+
<%= form_attribute_html(nil, as_(:export_format), safe_join(content), nil, {}) %>
|
|
29
57
|
<% end %>
|
|
30
|
-
|
|
58
|
+
<% else %>
|
|
59
|
+
<%= hidden_field_tag('format', export_config.formats[0]) %>
|
|
31
60
|
<% end %>
|
|
32
|
-
|
|
33
|
-
</div>
|
|
34
|
-
<div class="separator"></div>
|
|
61
|
+
<% end %>
|
|
@@ -21,10 +21,8 @@ module ActiveScaffold::Actions
|
|
|
21
21
|
def export
|
|
22
22
|
export_config = active_scaffold_config.export
|
|
23
23
|
if params[:export_columns].nil?
|
|
24
|
-
export_columns = {}
|
|
25
|
-
export_columns_names.each { |col| export_columns[col.to_sym] = 1 }
|
|
26
24
|
options = {
|
|
27
|
-
:export_columns =>
|
|
25
|
+
:export_columns => export_columns_names.map(&:to_s),
|
|
28
26
|
:full_download => export_config.default_full_download.to_s,
|
|
29
27
|
:delimiter => export_config.default_delimiter,
|
|
30
28
|
:skip_header => export_config.default_skip_header.to_s
|
|
@@ -111,9 +109,16 @@ module ActiveScaffold::Actions
|
|
|
111
109
|
|
|
112
110
|
def export_columns
|
|
113
111
|
return @export_columns if defined? @export_columns
|
|
114
|
-
|
|
115
|
-
params[:export_columns]
|
|
116
|
-
|
|
112
|
+
selected_columns = if params[:export_columns].respond_to?(:each_pair)
|
|
113
|
+
params[:export_columns].each_pair.filter_map { |name, selected| name.to_s if selected.present? }
|
|
114
|
+
else
|
|
115
|
+
Array(params[:export_columns]).reject(&:blank?).map(&:to_s)
|
|
116
|
+
end
|
|
117
|
+
available_columns = export_columns_names.map(&:to_s)
|
|
118
|
+
@export_columns = selected_columns.uniq.filter_map do |col|
|
|
119
|
+
next unless available_columns.include?(col)
|
|
120
|
+
next unless active_scaffold_config.model.authorized_for?(crud_type: :read, column: col.to_sym)
|
|
121
|
+
col
|
|
117
122
|
end
|
|
118
123
|
sorting = active_scaffold_config.list.user.sorting || active_scaffold_config.list.sorting
|
|
119
124
|
sorting_columns = sorting.reject { |col, _| @export_columns.include?(col.name) }.map(&:first)
|
|
@@ -12,6 +12,7 @@ module ActiveScaffold::Config
|
|
|
12
12
|
self.default_delimiter = self.class.default_delimiter
|
|
13
13
|
self.default_skip_header = self.class.default_skip_header
|
|
14
14
|
self.default_file_format = self.class.default_file_format
|
|
15
|
+
self.draggable = self.class.draggable
|
|
15
16
|
@formats = [:csv, :xlsx]
|
|
16
17
|
end
|
|
17
18
|
|
|
@@ -66,6 +67,10 @@ module ActiveScaffold::Config
|
|
|
66
67
|
cattr_accessor :default_file_format, instance_accessor: false
|
|
67
68
|
@@default_file_format = Gem::Specification::find_all_by_name('caxlsx').any? ? 'xlsx' : 'csv'
|
|
68
69
|
|
|
70
|
+
# whether selected export columns can be reordered with drag and drop
|
|
71
|
+
cattr_accessor :draggable, instance_accessor: false
|
|
72
|
+
@@draggable = false
|
|
73
|
+
|
|
69
74
|
# instance-level configuration
|
|
70
75
|
# ----------------------------
|
|
71
76
|
|
|
@@ -90,6 +95,9 @@ module ActiveScaffold::Config
|
|
|
90
95
|
# default file format to export, it can be changed in the form if show_form is enabled
|
|
91
96
|
attr_accessor :default_file_format
|
|
92
97
|
|
|
98
|
+
# whether selected export columns can be reordered with drag and drop
|
|
99
|
+
attr_accessor :draggable
|
|
100
|
+
|
|
93
101
|
def default_deselected_columns=(val)
|
|
94
102
|
@default_deselected_columns = ActiveScaffold::DataStructures::Set.new(*val)
|
|
95
103
|
end
|
|
@@ -99,21 +99,8 @@ module ActiveScaffold
|
|
|
99
99
|
rows = []
|
|
100
100
|
rows << [
|
|
101
101
|
[check_box_tag('skip_header', 1, export_config.default_skip_header), :omit_header],
|
|
102
|
-
[text_field_tag('delimiter', export_config.default_delimiter, :
|
|
102
|
+
[text_field_tag('delimiter', export_config.default_delimiter, size: 1, maxlength: 1, id: nil), :delimiter]
|
|
103
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
104
|
end
|
|
118
105
|
|
|
119
106
|
end
|
|
@@ -24,3 +24,5 @@ end
|
|
|
24
24
|
|
|
25
25
|
ActionView::Base.send(:include, ActiveScaffold::Helpers::ExportHelpers)
|
|
26
26
|
ActiveScaffold.stylesheets << 'active_scaffold_export'
|
|
27
|
+
ActiveScaffold.set_element :export_option, tag: :div, attributes: {class: 'export-option'}
|
|
28
|
+
ActiveScaffold.set_element :export_option_row, tag: :div, attributes: {class: 'export-option-row'}
|
metadata
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
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.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Volker Hochstein
|
|
8
8
|
- Sergio Cambra
|
|
9
9
|
- Hernan Astudillo
|
|
10
|
-
autorequire:
|
|
11
10
|
bindir: bin
|
|
12
11
|
cert_chain: []
|
|
13
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
14
13
|
dependencies:
|
|
15
14
|
- !ruby/object:Gem::Dependency
|
|
16
15
|
name: active_scaffold
|
|
@@ -18,14 +17,14 @@ dependencies:
|
|
|
18
17
|
requirements:
|
|
19
18
|
- - ">="
|
|
20
19
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 4.
|
|
20
|
+
version: 4.4.0
|
|
22
21
|
type: :runtime
|
|
23
22
|
prerelease: false
|
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
24
|
requirements:
|
|
26
25
|
- - ">="
|
|
27
26
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 4.
|
|
27
|
+
version: 4.4.0
|
|
29
28
|
description: Exporting Records with ActiveScaffold
|
|
30
29
|
email: activescaffold@googlegroups.com
|
|
31
30
|
executables: []
|
|
@@ -43,6 +42,8 @@ files:
|
|
|
43
42
|
- app/views/active_scaffold_overrides/_export_form_body.html.erb
|
|
44
43
|
- app/views/active_scaffold_overrides/_show_export.html.erb
|
|
45
44
|
- app/views/active_scaffold_overrides/show_export.html.erb
|
|
45
|
+
- config/locales/en.yml
|
|
46
|
+
- config/locales/es.yml
|
|
46
47
|
- lib/active_scaffold/actions/export.rb
|
|
47
48
|
- lib/active_scaffold/config/export.rb
|
|
48
49
|
- lib/active_scaffold/helpers/export_helpers.rb
|
|
@@ -54,7 +55,6 @@ homepage: http://github.com/active_scaffold/active_scaffold_export
|
|
|
54
55
|
licenses:
|
|
55
56
|
- MIT
|
|
56
57
|
metadata: {}
|
|
57
|
-
post_install_message:
|
|
58
58
|
rdoc_options: []
|
|
59
59
|
require_paths:
|
|
60
60
|
- lib
|
|
@@ -69,8 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
69
69
|
- !ruby/object:Gem::Version
|
|
70
70
|
version: '0'
|
|
71
71
|
requirements: []
|
|
72
|
-
rubygems_version: 3.
|
|
73
|
-
signing_key:
|
|
72
|
+
rubygems_version: 3.6.9
|
|
74
73
|
specification_version: 4
|
|
75
74
|
summary: Ability to export records to CSV/XLSX with ActiveScaffold
|
|
76
75
|
test_files: []
|