Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Dialog to set start and end records for export #2626

Closed
wants to merge 6 commits into from

5 participants

@ball-hayden

In response to #2449, I've created a modal dialog for setting start and end records when exporting using download links.

The PR also modifies apply_pagination so that it respects export[:start] and export[:end] parameters.

screenshot from 2013-10-27 22 24 16

Related: #1924

@seanlinsley
Owner

I've added a DSL that wraps jQuery UI modals over in #1815. Maybe this could use that once it's merged.

@ball-hayden

Definitely - that looks great.

Are you happy with the changes to lib/active_admin/resource_controller/data_access.rb to accept start and end parameters?

@abhimediratta
@ball-hayden

Set start to 1 and leave end blank.

@abhimediratta
@seanlinsley
Owner

@abhimediratta if you have a better idea then please discuss it over in #2449, or even open your own PR if you know exactly what you want.

@abhimediratta
@seanlinsley
Owner

Yeah I saw that, but "open source" doesn't mean "ask for features from random people on the internet and just expect them to do it". Right now no such feature exists, and we're working to change that. But if you're going to complain about the work done by @ball-hayden then you should suggest an alternative and/or implement it.

@abhimediratta
@ball-hayden

Perhaps an idea would be to have a config option to either:

  • Export current records (as it is at the moment)
  • Export all records
  • Show a dialog

Do you think it would be worth having a clear "all" option in the dialog (radio button all / select records)?

@macfanatic

@ball-hayden I like the thought of this, but I would like to see an inheritable setting that we could specify for the app, per namespace, or per resource with the options you mentioned above.

I definitely don't want the default behavior to be a modal popup for my projects either :)

@seanlinsley
Owner

While I'm not in love with the thought of a modal popup either, I think in any way promising to the user or developer that Active Admin can handle exporting all records is the wrong way to go. There either needs to be a hard limit like we had before, or some UI to help the user export the data in batches.

@ball-hayden

Slightly messily, I've rebased onto #1815 to use @seanlinsley's dialog DSL.

I'm going to have a look at adding configuration options.

@coveralls

Coverage Status

Coverage decreased (-0.22%) when pulling 704158d on ball-hayden:2449-better-exports into 37048c7 on gregbell:master.

@ball-hayden

I'm going to close this, as #3038 seems to be a much better solution.

@ball-hayden ball-hayden closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 31, 2013
  1. @seanlinsley @ball-hayden

    add modal dialog & dynamic form to Batch Actions

    seanlinsley authored ball-hayden committed
    thanks to @chrise86 for the updated CSS so this isn't horribly ugly
  2. @seanlinsley @ball-hayden

    update CSS so the overlay actually works again

    seanlinsley authored ball-hayden committed
  3. @ball-hayden
  4. @ball-hayden

    Change to use Modal DSL

    ball-hayden authored
Commits on Nov 1, 2013
  1. @ball-hayden
Commits on Nov 6, 2013
  1. @ball-hayden
This page is out of date. Refresh to see the latest.
Showing with 318 additions and 51 deletions.
  1. +31 −0 app/assets/javascripts/active_admin/components/aa.modal_dialog.js.coffee
  2. +8 −0 app/assets/javascripts/active_admin/components/jquery.serialize_object.js.coffee
  3. +19 −7 app/assets/javascripts/active_admin/pages/batch_actions.js.coffee
  4. +24 −0 app/assets/javascripts/active_admin/pages/export_form.js.coffee
  5. +1 −0  app/assets/stylesheets/active_admin/_base.css.scss
  6. +34 −0 app/assets/stylesheets/active_admin/components/_modal_dialog.scss
  7. +1 −0  config/locales/en.yml
  8. +14 −0 docs/3-index-pages.md
  9. +64 −0 features/index/export_behaviour.feature
  10. +20 −0 features/index/export_pagination.feature
  11. +11 −0 features/step_definitions/web_steps.rb
  12. +5 −2 lib/active_admin/application.rb
  13. +12 −7 lib/active_admin/batch_actions/controller.rb
  14. +23 −6 lib/active_admin/batch_actions/resource_extension.rb
  15. +6 −3 lib/active_admin/batch_actions/views/batch_action_form.rb
  16. +4 −12 lib/active_admin/batch_actions/views/batch_action_selector.rb
  17. +4 −0 lib/active_admin/resource/pagination.rb
  18. +19 −0 lib/active_admin/resource_controller/data_access.rb
  19. +4 −2 lib/active_admin/view_helpers/download_format_links_helper.rb
  20. +7 −6 lib/active_admin/views/components/paginated_collection.rb
  21. +7 −6 lib/active_admin/views/pages/index.rb
View
31 app/assets/javascripts/active_admin/components/aa.modal_dialog.js.coffee
@@ -0,0 +1,31 @@
+window.ActiveAdmin.modalDialog = (message, inputs, callback)->
+ html = """<form id="dialog_confirm" title="#{message}"><ul>"""
+ for name, type of inputs
+ if /^(datepicker|checkbox|text)$/.test type
+ wrapper = 'input'
+ else if type is 'textarea'
+ wrapper = 'textarea'
+ else if $.isArray type
+ [wrapper, elem, opts, type] = ['select', 'option', type, '']
+ else
+ console.warn "Unsupported input type: {#{name}: #{type}}"
+
+ klass = if type is 'datepicker' then type else ''
+ html += """<li>
+ <label>#{name.charAt(0).toUpperCase() + name.slice(1)}</label>
+ <#{wrapper} name="#{name}" class="#{klass}" type="#{type}">""" +
+ (if opts then ("<#{elem}>#{v}</#{elem}>" for v in opts).join '' else '') +
+ "</#{wrapper}>" +
+ "</li>"
+ [wrapper, elem, opts, type, klass] = [] # unset any temporary variables
+
+ html += "</ul></form>"
+ $(html).appendTo('body').dialog
+ modal: true
+ buttons:
+ OK: ->
+ callback $(@).serializeObject()
+ $(@).dialog('close')
+ Cancel: ->
+ $(@).dialog('close').remove()
+ $('input').blur() # prevent auto-focus event, so datepicker can be initialized
View
8 app/assets/javascripts/active_admin/components/jquery.serialize_object.js.coffee
@@ -0,0 +1,8 @@
+# `serializeArray` generates => [{ name: 'foo', value: 'bar' }]
+# This function remaps it to => { foo: 'bar' }
+jQuery ($)->
+ $.fn.serializeObject = ->
+ obj = {}
+ for o in @serializeArray()
+ obj[o.name] = o.value
+ obj
View
26 app/assets/javascripts/active_admin/pages/batch_actions.js.coffee
@@ -1,12 +1,24 @@
-jQuery ($) ->
+jQuery ($)->
#
- # Use Rails.js click handler to allow for Rails' confirm dialogs
+ # Use ActiveAdmin.modalDialog to prompt user if confirmation is required for current Batch Action
#
+ $('#batch_actions_selector li a').click (event)->
+ event.stopPropagation() # prevent Rails UJS click event
+ if message = $(@).data 'confirm'
+ ActiveAdmin.modalDialog message, $(@).data('inputs'), (inputs)=>
+ $(@).trigger 'confirm:complete', inputs
+ else
+ $(@).trigger 'confirm:complete'
+
+ $('#batch_actions_selector li a').on 'confirm:complete', (event, inputs)->
+ if val = JSON.stringify inputs
+ $('#batch_action_inputs').val val
+ else
+ $('#batch_action_inputs').attr 'disabled', 'disabled'
- $(document).delegate "#batch_actions_selector li a", "click.rails", ->
- $("#batch_action").val $(@).attr("data-action")
- $("#collection_selection").submit()
+ $('#batch_action').val $(@).data('action')
+ $('#collection_selection').submit()
#
# Add checkbox selection to resource tables and lists if batch actions are enabled
@@ -19,8 +31,8 @@ jQuery ($) ->
else
$(".paginated_collection").checkboxToggler()
- $(".paginated_collection").find(":checkbox").bind "change", ->
- if $(".paginated_collection").find(":checkbox").filter(":checked").length > 0
+ $(".paginated_collection :checkbox").change ->
+ if $(".paginated_collection :checkbox:checked").length
$("#batch_actions_selector").aaDropdownMenu("enable")
else
$("#batch_actions_selector").aaDropdownMenu("disable")
View
24 app/assets/javascripts/active_admin/pages/export_form.js.coffee
@@ -0,0 +1,24 @@
+jQuery ($) ->
+
+ $('[data-export-modal]').click (e) ->
+ e.preventDefault()
+
+ $btn = $(this)
+
+ inputs =
+ "export[start]": "text"
+ "export[end]": "text"
+
+ ActiveAdmin.modalDialog "Export Data", inputs, (inputs)=>
+ target = $btn.attr("href")
+
+ if target.indexOf("?") == -1
+ append = "?"
+ else
+ append = "&"
+
+ append += $.param(inputs)
+
+ window.location = target + append
+
+ return false
View
1  app/assets/stylesheets/active_admin/_base.css.scss
@@ -12,6 +12,7 @@
@import "active_admin/components/popovers";
@import "active_admin/components/tables";
@import "active_admin/components/batch_actions";
+@import "active_admin/components/modal_dialog";
@import "active_admin/components/blank_slates";
@import "active_admin/components/breadcrumbs";
@import "active_admin/components/dropdown_menu";
View
34 app/assets/stylesheets/active_admin/components/_modal_dialog.scss
@@ -0,0 +1,34 @@
+.ui-widget-overlay {
+ position: fixed;
+ background: rgba(0,0,0,.2);
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ z-index: 1001;
+}
+
+.ui-dialog {
+ position: fixed;
+ z-index: 1002;
+ @include section-background;
+ @include box-shadow(rgba(0,0,0,0.5) 0 0 10px);
+
+ .ui-dialog-titlebar {
+ @include section-header;
+ span { font-size: 1.1em; }
+ }
+ .ui-dialog-titlebar-close { visibility: hidden }
+
+ ul { list-style-type: none; }
+ li { margin: 10px 0; }
+ label { margin-right: 10px; }
+
+ .ui-dialog-buttonpane, form {
+ padding: 7px 15px 13px;
+ }
+ .ui-dialog-buttonpane button {
+ &:first-child { @include dark-button; } // OK
+ &:last-child { @include light-button; } // Cancel
+ }
+}
View
1  config/locales/en.yml
@@ -53,6 +53,7 @@ en:
link: "Create one"
batch_actions:
button_label: "Batch Actions"
+ default_confirmation: "Are you sure you want to do this? It might be irreversible."
delete_confirmation: "Are you sure you want to delete these %{plural_model}? You won't be able to undo this."
succesfully_destroyed:
one: "Successfully destroyed 1 %{model}"
View
14 docs/3-index-pages.md
@@ -204,3 +204,17 @@ ActiveAdmin.setup do |config|
end
```
+
+## Customizing Export Behaviour
+
+You can choose what you want to do when the user uses a download link:
+
+```ruby
+# Per resource:
+ActiveAdmin.register Post do
+
+ config.export_bahaviour = :modal
+ config.export_bahaviour = :paginate
+ config.export_bahaviour = :all
+
+end
View
64 features/index/export_behaviour.feature
@@ -0,0 +1,64 @@
+Feature: Export Behaviour
+
+ Allow developers to change the behaviour when exporting
+ records from ActiveAdmin
+
+ Background:
+ And a post with the title "Hello World" exists
+ And a post with the title "Hello World 2" exists
+ And I am logged in
+
+ Scenario: Default should show a modal
+ Given a configuration of:
+ """
+ ActiveAdmin.register Post do
+
+ end
+ """
+ When I am on the index page for posts
+ Then the "CSV" link should have the "data-export-modal" attribute
+
+ Scenario: Show a modal dialog
+ Given a configuration of:
+ """
+ ActiveAdmin.register Post do
+ config.export_behaviour = :modal
+ end
+ """
+ When I am on the index page for posts
+ Then the "CSV" link should have the "data-export-modal" attribute
+
+ Scenario: Export all
+ Given a configuration of:
+ """
+ ActiveAdmin.register Post do
+ config.per_page = 1
+
+ config.export_behaviour = :all
+ end
+ """
+ When I am on the index page for posts
+ Then the "CSV" link should not have the "data-export-modal" attribute
+
+ When I click "CSV"
+ And I should download a CSV file for "posts" containing:
+ | Id | Title | Body | Published At | Starred | Created At | Updated At |
+ | \d+ | Hello World 2 | | | | (.*) | (.*) |
+ | \d+ | Hello World | | | | (.*) | (.*) |
+
+ Scenario: Export current page
+ Given a configuration of:
+ """
+ ActiveAdmin.register Post do
+ config.per_page = 1
+
+ config.export_behaviour = :paginate
+ end
+ """
+ When I am on the index page for posts
+ Then the "CSV" link should not have the "data-export-modal" attribute
+
+ When I click "CSV"
+ And I should download a CSV file for "posts" containing:
+ | Id | Title | Body | Published At | Starred | Created At | Updated At |
+ | \d+ | Hello World 2 | | | | (.*) | (.*) |
View
20 features/index/export_pagination.feature
@@ -0,0 +1,20 @@
+Feature: Index Export Pagination
+
+ Background:
+ Given an index configuration of:
+ """
+ ActiveAdmin.register Post
+ """
+ And 20 posts exist
+
+ Scenario: Export with only start parameter set
+ When I am on the index page for posts with params "?export%5Bstart%5D=5"
+ Then the table "#index_table_posts" should have 16 rows (including the header row)
+
+ Scenario: Export with only end parameter set
+ When I am on the index page for posts with params "?export%5Bend%5D=5"
+ Then the table "#index_table_posts" should have 6 rows (including the header row)
+
+ Scenario: Export with start and end parameter set
+ When I am on the index page for posts with params "?export%5Bstart%5D=5&export%5Bend%5D=15"
+ Then the table "#index_table_posts" should have 11 rows (including the header row)
View
11 features/step_definitions/web_steps.rb
@@ -61,6 +61,10 @@ def with_scope(locator)
page.send should, have
end
+Then /^I should see a dialog$/ do
+ page.should have_css(".ui-dialog")
+end
+
Then /^the "([^"]*)" field(?: within (.*))? should( not)? contain "([^"]*)"$/ do |field, parent, negate, value|
with_scope(parent) do
field = find_field(field)
@@ -81,6 +85,13 @@ def with_scope(locator)
current_path.should == path_to(page_name)
end
+Then /^the "(.*?)" link should( not)? have the "(.*?)" attribute$/ do |link_name, negate, attribute|
+ should = negate ? :should_not : :should
+
+ link = find_link(link_name)
+ link[attribute].send should, nil
+end
+
Then /^show me the page$/ do
save_and_open_page
end
View
7 lib/active_admin/application.rb
@@ -36,7 +36,7 @@ def initialize
# Set the site title image displayed in the main layout (has precendence over :site_title)
inheritable_setting :site_title_image, ""
-
+
# Set a favicon
inheritable_setting :favicon, false
@@ -73,6 +73,9 @@ def initialize
# Default Download Links options
inheritable_setting :download_links, true
+ # Default Export Behaviour options
+ inheritable_setting :export_behaviour, :modal
+
# The authorization adapter to use
inheritable_setting :authorization_adapter, ActiveAdmin::AuthorizationAdapter
@@ -218,7 +221,7 @@ def remove_active_admin_load_paths_from_rails_autoload_and_eager_load
ActiveSupport::Dependencies.autoload_paths.reject!{ |path| load_paths.include? path }
Rails.application.config.eager_load_paths = # the array is frozen :/
Rails.application.config.eager_load_paths.reject do |path|
- load_paths.include?(path)
+ load_paths.include?(path)
end
end
View
19 lib/active_admin/batch_actions/controller.rb
@@ -2,11 +2,13 @@ module ActiveAdmin
module BatchActions
module Controller
- # Controller Action that get's called when submitting the batch action form
+ # Controller action that is called when submitting the batch action form
def batch_action
- if selected_batch_action
- selected_ids = params[:collection_selection] || []
- instance_exec selected_ids, &selected_batch_action.block
+ if action_present?
+ selection = params[:collection_selection] || []
+ inputs = JSON.parse params[:batch_action_inputs] || '{}'
+ inputs = inputs.with_indifferent_access.slice *current_batch_action.inputs.keys
+ instance_exec selection, inputs, &current_batch_action.block
else
raise "Couldn't find batch action \"#{params[:batch_action]}\""
end
@@ -14,9 +16,12 @@ def batch_action
protected
- def selected_batch_action
- return unless params[:batch_action].present?
- active_admin_config.batch_actions.detect { |action| action.sym.to_s == params[:batch_action] }
+ def action_present?
+ params[:batch_action].present? && current_batch_action
+ end
+
+ def current_batch_action
+ active_admin_config.batch_actions.detect{ |action| action.sym.to_s == params[:batch_action] }
end
end
View
29 lib/active_admin/batch_actions/resource_extension.rb
@@ -31,7 +31,8 @@ def batch_actions=(bool)
# @param [Hash] options
# => :if is a proc that will be called to determine if the BatchAction should be displayed
# => :sort_order is used to sort the batch actions ascending
- # => :confirm is a string which the user will have to accept in order to process the action
+ # => :confirm is a string to prompt the user with (or a boolean to use the default message)
+ # => :form is a Hash of form fields you want the user to fill out
#
def add_batch_action(sym, title, options = {}, &block)
@batch_actions[sym] = ActiveAdmin::BatchAction.new(sym, title, options, &block)
@@ -61,8 +62,8 @@ def batch_action_path(params = {})
def add_default_batch_actions
destroy_options = {
:priority => 100,
- :confirm => proc { I18n.t('active_admin.batch_actions.delete_confirmation', :plural_model => active_admin_config.plural_resource_label.downcase) },
- :if => proc{ controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, active_admin_config.resource_class) }
+ :confirm => proc{ I18n.t('active_admin.batch_actions.delete_confirmation', :plural_model => active_admin_config.plural_resource_label.downcase) },
+ :if => proc{ controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, active_admin_config.resource_class) }
}
add_batch_action :destroy, proc { I18n.t('active_admin.delete') }, destroy_options do |selected_ids|
@@ -83,7 +84,9 @@ class BatchAction
include Comparable
- attr_reader :block, :title, :sym, :confirm
+ attr_reader :block, :title, :sym
+
+ DEFAULT_CONFIRM_MESSAGE = proc{ I18n.t 'active_admin.batch_actions.default_confirmation' }
# Create a Batch Action
#
@@ -99,17 +102,31 @@ class BatchAction
# => You can create batch actions with a title instead of a Symbol
#
# BatchAction.new( :flag, :if => proc { can? :flag, AdminUser } ) { |selection| }
- # => You can provide an optional :if proc to optionally display the batch action
+ # => You can provide an optional `:if` proc to optionally display the batch action
+ #
+ # BatchAction.new( :flag, :confirm => "Are you sure?" ) { |selection| }
+ # => You can pass `true` to use the default confirm message, or pass a string to set your own.
+ #
+ # BatchAction.new( :flag, :confirm => true, :form => {:foo => :text, :bar => :checkbox} ) { |selection, inputs| }
+ # => You can pass a hash of options to `:form` that will be rendered as form input fields for the user to fill out.
#
def initialize(sym, title, options = {}, &block)
@sym, @title, @options, @block, @confirm = sym, title, options, block, options[:confirm]
@block ||= proc {}
end
+ def confirm
+ @confirm == true ? DEFAULT_CONFIRM_MESSAGE : @confirm
+ end
+
+ def inputs
+ HashWithIndifferentAccess.new @options[:form] || {}
+ end
+
# Returns the display if block. If the block was not explicitly defined
# a default block always returning true will be returned.
def display_if_block
- @options[:if] || proc { true }
+ @options[:if] || proc{ true }
end
# Used for sorting
View
9 lib/active_admin/batch_actions/views/batch_action_form.rb
@@ -3,7 +3,7 @@
module ActiveAdmin
module BatchActions
- # Build an BatchActionForm
+ # Build a BatchActionForm
class BatchActionForm < ActiveAdmin::Component
builder_method :batch_action_form
@@ -12,9 +12,12 @@ class BatchActionForm < ActiveAdmin::Component
def build(options = {}, &block)
options[:id] ||= "collection_selection"
- # Open a form
+ # Open a form with two hidden input fields:
+ # batch_action => name of the specific action called
+ # batch_action_inputs => a JSON string of any requested confirmation values
text_node form_tag(active_admin_config.batch_action_path(params), :id => options[:id])
- input(:name => :batch_action, :id => :batch_action, :type => :hidden)
+ input :name => :batch_action, :id => :batch_action, :type => :hidden
+ input :name => :batch_action_inputs, :id => :batch_action_inputs, :type => :hidden
super(options)
end
View
16 lib/active_admin/batch_actions/views/batch_action_selector.rb
@@ -30,9 +30,10 @@ def build_drop_down
confirmation_text = render_or_call_method_or_proc_on(self, batch_action.confirm)
options = {
- :class => "batch_action",
- "data-action" => batch_action.sym,
- "data-confirm" => confirmation_text
+ :class => "batch_action",
+ "data-action" => batch_action.sym,
+ "data-confirm" => confirmation_text,
+ "data-inputs" => batch_action.inputs.to_json
}
default_title = render_or_call_method_or_proc_on(self, batch_action.title)
@@ -51,15 +52,6 @@ def batch_actions_to_display
end
end
- # def build_batch_action_button
- # a :class => 'table_tools_button dropdown_button disabled', :href => "#batch_actions_popover", :id => "batch_actions_button" do
- # text_node I18n.t("active_admin.batch_actions.button_label")
- # end
- # end
-
- # def build_batch_action_popover
- # end
-
end
end
View
4 lib/active_admin/resource/pagination.rb
@@ -9,10 +9,14 @@ module Pagination
# Enable / disable pagination (defaults to true)
attr_accessor :paginate
+ # Export Behaviour
+ attr_accessor :export_behaviour
+
def initialize(*args)
super
@paginate = true
@per_page = namespace.default_per_page
+ @export_behaviour = namespace.export_behaviour
end
end
end
View
19 lib/active_admin/resource_controller/data_access.rb
@@ -272,9 +272,28 @@ def apply_pagination(chain)
page_method = Kaminari.config.page_method_name
page_param = params[Kaminari.config.param_name]
+ return apply_export_pagination(chain, page_method, page_param) if params.keys.include? "export"
+
chain.send(page_method, page_param).per(per_page)
end
+ # Applies pagination based on start and end parameters.
+ # If only start is given, assume the last record is the end.
+ def apply_export_pagination(chain, page_method, page_param)
+ if active_admin_config.export_behaviour == :all
+ count = chain.size
+ else
+ start = params[:export][:start]
+ count = (params[:export][:end] || chain.size).to_i
+ count -= start.to_i unless start.nil?
+ end
+
+ chain = chain.send(page_method, page_param).per(count)
+ chain = chain.padding(start) unless start.nil?
+
+ chain
+ end
+
def per_page
return max_per_page if active_admin_config.paginate == false
View
6 lib/active_admin/view_helpers/download_format_links_helper.rb
@@ -32,9 +32,11 @@ def add_format extension
end
# TODO: Refactor to new HTML DSL
- def build_download_format_links(formats = self.class.formats)
+ def build_download_format_links(export_behaviour, formats = self.class.formats)
params = request.query_parameters.except :format, :commit
- links = formats.map { |format| link_to format.to_s.upcase, params: params, format: format }
+
+ link_options = { data: { "export-modal" => true } } if export_behaviour == :modal
+ links = formats.map { |format| link_to format.to_s.upcase, { params: params, format: format, export: { exporting: true } }, link_options || {} }
div :class => "download_links" do
text_node [I18n.t('active_admin.download'), links].flatten.join("&nbsp;").html_safe
end
View
13 lib/active_admin/views/components/paginated_collection.rb
@@ -36,10 +36,11 @@ class PaginatedCollection < ActiveAdmin::Component
# download_links => Download links override (false or [:csv, :pdf])
#
def build(collection, options = {})
- @collection = collection
- @param_name = options.delete(:param_name)
- @download_links = options.delete(:download_links)
- @display_total = options.delete(:pagination_total) { true }
+ @collection = collection
+ @param_name = options.delete(:param_name)
+ @download_links = options.delete(:download_links)
+ @export_behaviour = options.delete(:export_behaviour)
+ @display_total = options.delete(:pagination_total) { true }
unless collection.respond_to?(:num_pages)
raise(StandardError, "Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.")
@@ -69,9 +70,9 @@ def build_pagination_with_formats(options)
download_links = @download_links.is_a?(Proc) ? instance_exec(&@download_links) : @download_links
if download_links.is_a?(Array) && !download_links.empty?
- build_download_format_links download_links
+ build_download_format_links @export_behaviour, download_links
else
- build_download_format_links unless download_links == false
+ build_download_format_links @export_behaviour unless download_links == false
end
end
View
13 lib/active_admin/views/pages/index.rb
@@ -125,14 +125,15 @@ def render_empty_results
def render_index
renderer_class = find_index_renderer_class(config[:as])
- paginator = config[:paginator].nil? ? true : config[:paginator]
- download_links = config[:download_links].nil? ? active_admin_config.namespace.download_links : config[:download_links]
+ paginator = config[:paginator].nil? ? true : config[:paginator]
+ download_links = config[:download_links].nil? ? active_admin_config.namespace.download_links : config[:download_links]
pagination_total = config[:pagination_total].nil? ? true : config[:pagination_total]
- paginated_collection(collection, :entry_name => active_admin_config.resource_label,
- :entries_name => active_admin_config.plural_resource_label(:count => collection_size),
- :download_links => download_links,
- :paginator => paginator,
+ paginated_collection(collection, :entry_name => active_admin_config.resource_label,
+ :entries_name => active_admin_config.plural_resource_label(:count => collection_size),
+ :download_links => download_links,
+ :export_behaviour => active_admin_config.export_behaviour,
+ :paginator => paginator,
:pagination_total => pagination_total) do
div :class => 'index_content' do
insert_tag(renderer_class, config, collection)
Something went wrong with that request. Please try again.