active_scaffold_export 3.3.2 → 3.4.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
- SHA1:
3
- metadata.gz: a839bd6f44ec26aa73f8da128adc2678f87f65dc
4
- data.tar.gz: 0377be1f4026ebbae123d012b7faa1938fef34f3
2
+ SHA256:
3
+ metadata.gz: e9f7f034474f62c9c156d57118a1cf6c36b8f704d3e3d39b9df7ca352c238d4a
4
+ data.tar.gz: f1d0c02ad1a4e503a00bc55459771a6853597cc99b5e1c869b22a11fc8539f43
5
5
  SHA512:
6
- metadata.gz: 75e352107ecc0d1fb6e4f80444f56806cc62a3d6a3fb18eb3a5ab68a0fbeac02ce8248595b65c4563e1b3c0995b21e8cfb73d80fb1488265e876541eab65d480
7
- data.tar.gz: 15964ca9effd8a6b8fba7d48d86ee7cf9f381be1d486ec65179278872c047bb6aaa065fe979c3003b23bf9518fb5190cf7301e66c46e6f0859b9abd28039bbfb
6
+ metadata.gz: 428f1456d4c2c96d756bc1bc9007de918233d6fb5104e4915a329a64a9e09e434db5c0e29babec790ba7facc4539d928c02d890e48dc1416fe96a8315a9baccd
7
+ data.tar.gz: a4cd29b6d36228116cb2064592b8323a26aea1689fb27d6119432775b1f611474138adadfd1f27c2d147f44c69e8c4b16ba8855aa47e39cd1eac3c9306bceeae
@@ -1,12 +1,12 @@
1
1
  <% export_config = active_scaffold_config.export %>
2
2
  <h3><%=as_(:columns_for_export)%></h3>
3
- <% if ActiveScaffold.js_framework == :jquery %>
4
- <%= link_to as_(:select_all), '#', onclick: 'jQuery(".columnCheckbox").prop("checked", true);', class: 'active-scaffold-footer' %>
3
+ <% if ActiveScaffold.js_framework == :jquery # TODO: use JS asset instead of inline JS %>
4
+ <%= link_to as_(:select_all), '#', onclick: 'jQuery(".columnCheckbox").prop("checked", true); return false', class: 'active-scaffold-footer' %>
5
5
  |
6
- <%= link_to as_(:select_none), '#', onclick: 'jQuery(".columnCheckbox").prop("checked", false);', class: 'active-scaffold-footer' %>
6
+ <%= link_to as_(:select_none), '#', onclick: 'jQuery(".columnCheckbox").prop("checked", false); return false', class: 'active-scaffold-footer' %>
7
7
  <% end %>
8
8
  <div class="columns checkbox-list">
9
- <% export_config.columns.each do |column| -%>
9
+ <% export_config.columns.each_column do |column| -%>
10
10
  <div class="column checkbox-wrapper">
11
11
  <%= content_tag(:label, check_box_tag("export_columns[#{column.name}]", 1, !export_config.default_deselected_columns.include?(column.name), :class => 'columnCheckbox') + "&nbsp;#{column.label}".html_safe) %>
12
12
  </div>
@@ -4,4 +4,5 @@
4
4
  :method => :post,
5
5
  :cancel_link => true,
6
6
  :headline => as_(:export),
7
- :body_partial => 'export_form_body'} %>
7
+ :body_partial => 'export_form_body',
8
+ :loading => false} %>
@@ -1,13 +1,8 @@
1
1
  module ActiveScaffold::Actions
2
2
  module Export
3
3
  def self.included(base)
4
- base.before_filter :export_authorized?, :only => [:export]
5
- base.before_filter :show_export_authorized?, :only => [:show_export]
6
- base.before_filter :init_session_var
7
- end
8
-
9
- def init_session_var
10
- session[:search] = params[:search] if !params[:search].nil? || params[:commit] == as_('Search')
4
+ base.before_action :export_authorized?, :only => [:export]
5
+ base.before_action :show_export_authorized?, :only => [:show_export]
11
6
  end
12
7
 
13
8
  # display the customization form or skip directly to export
@@ -28,9 +23,7 @@ module ActiveScaffold::Actions
28
23
  export_config = active_scaffold_config.export
29
24
  if params[:export_columns].nil?
30
25
  export_columns = {}
31
- export_config.columns.each { |col|
32
- export_columns[col.name.to_sym] = 1
33
- }
26
+ export_config.columns.each { |col| export_columns[col.to_sym] = 1 }
34
27
  options = {
35
28
  :export_columns => export_columns,
36
29
  :full_download => export_config.default_full_download.to_s,
@@ -40,9 +33,7 @@ module ActiveScaffold::Actions
40
33
  params.merge!(options)
41
34
  end
42
35
 
43
- @export_columns = export_config.columns.reject { |col| params[:export_columns][col.name.to_sym].nil? }
44
- includes_for_export_columns = @export_columns.collect{ |col| col.includes }.flatten.uniq.compact
45
- self.active_scaffold_includes.concat includes_for_export_columns
36
+ set_includes_for_columns(:export)
46
37
  @export_config = export_config
47
38
  # Make sure active_scaffold's find_page is dealing with the same list of
48
39
  # columns. Prevents an invalid SQL query when exporting after filtering
@@ -83,7 +74,7 @@ module ActiveScaffold::Actions
83
74
  sheet.add_row(@export_columns.collect { |column| view_context.format_export_column_header_name(column) }, style: header) unless params[:skip_header]
84
75
  find_items_for_export do |records|
85
76
  records.each do |record|
86
- sheet.add_row @export_columns.collect{|column| view_context.get_export_column_value(record, column, false)}
77
+ sheet.add_row @export_columns.collect { |column| view_context.get_export_column_value(record, column, false) }
87
78
  end
88
79
  end
89
80
  end
@@ -97,6 +88,15 @@ module ActiveScaffold::Actions
97
88
  end
98
89
 
99
90
  protected
91
+ def export_columns
92
+ return @export_columns if defined? @export_columns
93
+ @export_columns = active_scaffold_config.export.columns.reject { |col| params[:export_columns][col.to_sym].nil? }
94
+ sorting = active_scaffold_config.list.user.sorting || active_scaffold_config.list.sorting
95
+ sorting_columns = sorting.reject { |col, _| @export_columns.include?(col.name) }.map(&:first)
96
+ @export_columns.map! { |col| active_scaffold_config.columns[col] }
97
+ @export_columns += sorting_columns
98
+ end
99
+
100
100
  # The actual algorithm to do the export
101
101
  def find_items_for_export(&block)
102
102
  find_options = { :sorting =>
@@ -104,7 +104,6 @@ module ActiveScaffold::Actions
104
104
  active_scaffold_config.list.sorting : active_scaffold_config.list.user.sorting,
105
105
  :pagination => true
106
106
  }
107
- params[:search] = session[:search]
108
107
  do_search rescue nil
109
108
  params[:segment_id] = session[:segment_id]
110
109
  do_segment_search rescue nil
@@ -130,7 +129,7 @@ module ActiveScaffold::Actions
130
129
  # The default name of the downloaded file.
131
130
  # You may override the method to specify your own file name generation.
132
131
  def export_file_name
133
- filename = self.controller_name
132
+ filename = self.controller_name.clone
134
133
 
135
134
  if params[:format]
136
135
  if params[:format].to_sym == :xlsx
@@ -69,15 +69,7 @@ module ActiveScaffold::Config
69
69
  Gem::Specification::find_all_by_name('axlsx_rails').any?
70
70
  end
71
71
 
72
- # provides access to the list of columns specifically meant for this action to use
73
- def columns
74
- self.columns = @core.columns._inheritable unless @columns
75
- @columns
76
- end
77
- def columns=(val)
78
- @columns = ActiveScaffold::DataStructures::ActionColumns.new(*val)
79
- @columns.action = self
80
- end
72
+ columns_accessor :columns
81
73
 
82
74
  def multipart?
83
75
  false
@@ -17,12 +17,11 @@ module ActiveScaffold
17
17
 
18
18
  if column.association.nil? or column_empty?(raw_value)
19
19
  csv ? format_export_column(raw_value) : raw_value # xlsx needs original data type
20
- else
21
- case column.association.macro
22
- when :has_one, :belongs_to
23
- format_singular_association_export_column(raw_value)
24
- when :has_many, :has_and_belongs_to_many
20
+ elsif column.association
21
+ if column.association.collection?
25
22
  format_plural_association_export_column(raw_value)
23
+ else
24
+ format_singular_association_export_column(raw_value)
26
25
  end
27
26
  end
28
27
  end
@@ -15,6 +15,6 @@ ActiveScaffold::Config::Core.class_eval do
15
15
  :export_default_delimiter, :export_default_skip_header,
16
16
  :export_default_file_format, :export_xlsx_avaliable
17
17
 
18
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:show_export] = :get
19
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:export] = :post
18
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:show_export] = :get
19
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:export] = :post
20
20
  end
@@ -1,8 +1,8 @@
1
1
  module ActiveScaffoldExport
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 3
5
- PATCH = 2
4
+ MINOR = 4
5
+ PATCH = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_export
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Volker Hochstein
8
8
  - Sergio Cambra
9
9
  - Hernan Astudillo
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-01-04 00:00:00.000000000 Z
13
+ date: 2020-12-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: active_scaffold
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: 3.3.0.rc
21
+ version: 3.6.0.pre
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: 3.3.0.rc
28
+ version: 3.6.0.pre
29
29
  description: Exporting Records with ActiveScaffold
30
30
  email: activescaffold@googlegroups.com
31
31
  executables: []
@@ -34,11 +34,8 @@ extra_rdoc_files:
34
34
  - LICENSE.txt
35
35
  - README.md
36
36
  files:
37
- - ".document"
38
37
  - LICENSE.txt
39
38
  - README.md
40
- - Rakefile
41
- - active_scaffold_export.gemspec
42
39
  - app/assets/images/export.png
43
40
  - app/assets/stylesheets/active_scaffold_export.css.erb
44
41
  - app/assets/stylesheets/export-stylesheet-ie.css
@@ -46,7 +43,6 @@ files:
46
43
  - app/views/active_scaffold_overrides/_export_form_body.html.erb
47
44
  - app/views/active_scaffold_overrides/_show_export.html.erb
48
45
  - app/views/active_scaffold_overrides/show_export.html.erb
49
- - init.rb
50
46
  - lib/active_scaffold/actions/export.rb
51
47
  - lib/active_scaffold/config/export.rb
52
48
  - lib/active_scaffold/helpers/export_helpers.rb
@@ -54,11 +50,11 @@ files:
54
50
  - lib/active_scaffold_export/config/core.rb
55
51
  - lib/active_scaffold_export/engine.rb
56
52
  - lib/active_scaffold_export/version.rb
57
- homepage: http://github.com/naaano/active_scaffold_export
53
+ homepage: http://github.com/active_scaffold/active_scaffold_export
58
54
  licenses:
59
55
  - MIT
60
56
  metadata: {}
61
- post_install_message:
57
+ post_install_message:
62
58
  rdoc_options: []
63
59
  require_paths:
64
60
  - lib
@@ -73,9 +69,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
69
  - !ruby/object:Gem::Version
74
70
  version: '0'
75
71
  requirements: []
76
- rubyforge_project:
77
- rubygems_version: 2.4.5
78
- signing_key:
72
+ rubyforge_project:
73
+ rubygems_version: 2.7.9
74
+ signing_key:
79
75
  specification_version: 4
80
76
  summary: Ability to export records to CSV/XLSX with ActiveScaffold
81
77
  test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/Rakefile DELETED
@@ -1,55 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
-
12
- require 'jeweler'
13
- require './lib/active_scaffold_export/version.rb'
14
-
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "active_scaffold_export"
18
- gem.version = ActiveScaffoldExport::Version::STRING
19
- gem.homepage = "http://github.com/naaano/active_scaffold_export"
20
- gem.license = "MIT"
21
- gem.summary = %Q{Exporting Records with ActiveScaffold}
22
- gem.description = %Q{Exporting Records with ActiveScaffold}
23
- gem.email = "activescaffold@googlegroups.com"
24
- gem.authors = ["Volker Hochstein", "Sergio Cambra", "Hernan Astudillo"]
25
- gem.add_runtime_dependency 'active_scaffold', '~> 3.1'
26
- # Include your dependencies below. Runtime dependencies are required when using your gem,
27
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
28
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
29
- # gem.add_development_dependency 'rspec', '> 1.2.3'
30
- end
31
- Jeweler::RubygemsDotOrgTasks.new
32
-
33
- require 'rake/testtask'
34
- Rake::TestTask.new(:test) do |test|
35
- test.libs << 'lib' << 'test'
36
- test.pattern = 'test/**/test_*.rb'
37
- test.verbose = true
38
- end
39
-
40
- require 'rcov/rcovtask'
41
- Rcov::RcovTask.new do |test|
42
- test.libs << 'test'
43
- test.pattern = 'test/**/test_*.rb'
44
- test.verbose = true
45
- end
46
-
47
- task :default => :test
48
-
49
- require 'rake/rdoctask'
50
- Rake::RDocTask.new do |rdoc|
51
- rdoc.rdoc_dir = 'rdoc'
52
- rdoc.title = "active_scaffold_export #{ActiveScaffoldExport::Version::STRING}"
53
- rdoc.rdoc_files.include('README*')
54
- rdoc.rdoc_files.include('lib/**/*.rb')
55
- end
@@ -1,44 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "active_scaffold_export"
8
- s.version = "3.3.2"
9
-
10
- s.authors = ["Volker Hochstein", "Sergio Cambra", "Hernan Astudillo"]
11
- s.description = "Exporting Records with ActiveScaffold"
12
- s.email = "activescaffold@googlegroups.com"
13
- s.extra_rdoc_files = [
14
- "LICENSE.txt",
15
- "README.md"
16
- ]
17
- s.files = [
18
- ".document",
19
- "LICENSE.txt",
20
- "README.md",
21
- "Rakefile",
22
- "init.rb",
23
- "active_scaffold_export.gemspec",
24
- "app/assets/images/export.png",
25
- "app/assets/stylesheets/active_scaffold_export.css.erb",
26
- "app/assets/stylesheets/export-stylesheet-ie.css",
27
- "app/views/active_scaffold_overrides/_export.csv.erb",
28
- "app/views/active_scaffold_overrides/_export_form_body.html.erb",
29
- "app/views/active_scaffold_overrides/_show_export.html.erb",
30
- "app/views/active_scaffold_overrides/show_export.html.erb",
31
- "lib/active_scaffold/actions/export.rb",
32
- "lib/active_scaffold/config/export.rb",
33
- "lib/active_scaffold/helpers/export_helpers.rb",
34
- "lib/active_scaffold_export.rb",
35
- "lib/active_scaffold_export/config/core.rb",
36
- "lib/active_scaffold_export/engine.rb",
37
- "lib/active_scaffold_export/version.rb"
38
- ]
39
- s.homepage = "http://github.com/naaano/active_scaffold_export"
40
- s.licenses = ["MIT"]
41
- s.require_paths = ["lib"]
42
- s.summary = "Ability to export records to CSV/XLSX with ActiveScaffold"
43
- s.add_runtime_dependency 'active_scaffold', '>= 3.3.0.rc'
44
- end
data/init.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'active_scaffold_export'
2
-
3
- begin
4
- ActiveScaffoldAssets.copy_to_public(ActiveScaffoldExport.root)
5
- rescue
6
- raise $! unless Rails.env == 'production'
7
- end