-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f45042a
commit b11db54
Showing
6 changed files
with
38 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module ActiveAdmin | ||
class CSVBuilder | ||
def build(controller, csv) | ||
@collection = controller.send :find_collection, except: :pagination | ||
columns = exec_columns controller.view_context | ||
options = ActiveAdmin.application.csv_options.merge self.options | ||
bom = options.delete :byte_order_mark | ||
column_names = options.delete(:column_names) { true } | ||
csv_options = options.except :encoding_options, :humanize_name | ||
|
||
csv << bom if bom | ||
|
||
if column_names | ||
csv << CSV.generate_line(columns.map{ |c| encode c.name, options }, csv_options) | ||
end | ||
|
||
(1..paginated_collection.total_pages).each do |page| | ||
paginated_collection(page).each do |resource| | ||
resource = controller.send :apply_decorator, resource | ||
csv << CSV.generate_line(build_row(resource, columns, options), csv_options) | ||
end | ||
end | ||
|
||
csv | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters