Class: ActiveScaffold::Config::Export

Inherits:
Form
  • Object
show all
Defined in:
lib/active_scaffold/config/export.rb

Constant Summary collapse

ActiveScaffold::DataStructures::ActionLink.new('show_export', :label => :export, :type => :collection, :security_method => :export_authorized?)
@@plugin_directory =
@@show_form =
true
@@allow_full_download =
true
@@force_quotes =
false
@@default_full_download =
true
@@default_delimiter =
','
@@default_skip_header =
false
@@default_file_format =
Gem::Specification::find_all_by_name('caxlsx').any? ? 'xlsx' : 'csv'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(core_config) ⇒ Export

Returns a new instance of Export.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/active_scaffold/config/export.rb', line 5

def initialize(core_config)
  super
  @core = core_config
  self.show_form = self.class.show_form
  self.allow_full_download = self.class.allow_full_download
  self.force_quotes = self.class.force_quotes
  self.default_full_download = self.class.default_full_download
  self.default_delimiter = self.class.default_delimiter
  self.default_skip_header = self.class.default_skip_header
  self.default_file_format = self.class.default_file_format
  @formats = [:csv, :xlsx]
end

Instance Attribute Details

#allow_full_downloadObject

whether user can ask for full or page export, or default is forced



76
77
78
# File 'lib/active_scaffold/config/export.rb', line 76

def allow_full_download
  @allow_full_download
end

#default_delimiterObject

default column separator for CSV, it can be changed in the form if show_form is enabled



85
86
87
# File 'lib/active_scaffold/config/export.rb', line 85

def default_delimiter
  @default_delimiter
end

#default_file_formatObject

default file format to export, it can be changed in the form if show_form is enabled



91
92
93
# File 'lib/active_scaffold/config/export.rb', line 91

def default_file_format
  @default_file_format
end

#default_full_downloadObject

default setting for full export or page export, it can be changed in the form if show_form is enabled



82
83
84
# File 'lib/active_scaffold/config/export.rb', line 82

def default_full_download
  @default_full_download
end

#default_skip_headerObject

wheter export a header (false) or skip exporting a header (true), it can be changed in the form if show_form is enabled



88
89
90
# File 'lib/active_scaffold/config/export.rb', line 88

def default_skip_header
  @default_skip_header
end

#force_quotesObject

force_quotes option for CSV library



79
80
81
# File 'lib/active_scaffold/config/export.rb', line 79

def force_quotes
  @force_quotes
end


33
34
35
36
37
38
39
# File 'lib/active_scaffold/config/export.rb', line 33

def link
  @link ||= if show_form
    self.class.link.clone
  else
    ActiveScaffold::DataStructures::ActionLink.new('export', :label => :export, :type => :collection, :inline => false, :security_method => :export_authorized?)
  end
end

#show_formObject

whether open a form to allow selecting columns and format settings, or export directly with the defined settings in the controller



73
74
75
# File 'lib/active_scaffold/config/export.rb', line 73

def show_form
  @show_form
end

Instance Method Details

#default_deselected_columnsObject



97
98
99
100
# File 'lib/active_scaffold/config/export.rb', line 97

def default_deselected_columns
  self.default_deselected_columns = ActiveScaffold::DataStructures::Set.new if @default_deselected_columns.nil?
  @default_deselected_columns
end

#default_deselected_columns=(val) ⇒ Object



93
94
95
# File 'lib/active_scaffold/config/export.rb', line 93

def default_deselected_columns=(val)
  @default_deselected_columns = ActiveScaffold::DataStructures::Set.new(*val)
end

#multipart?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/active_scaffold/config/export.rb', line 104

def multipart?
  false
end