lib/active_admin/views/components/paginated_collection.rb in activeadmin-0.5.1 vs lib/active_admin/views/components/paginated_collection.rb in activeadmin-0.6.0
- old
+ new
@@ -27,27 +27,25 @@
attr_reader :collection
# Builds a new paginated collection component
#
- # @param [Array] collection A "paginated" collection from kaminari
- # @param [Hash] options These options will be passed on to the page_entries_info
- # method.
- # Useful keys:
- # :entry_name - The name to display for this resource collection
- # :param_name - Parameter name for page number in the links (:page by default)
- # :download_links - Set to false to skip download format links
+ # collection => A paginated collection from kaminari
+ # options => These options will be passed to `page_entries_info`
+ # entry_name => The name to display for this resource collection
+ # param_name => Parameter name for page number in the links (:page by default)
+ # 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)
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.")
end
-
@contents = div(:class => "paginated_collection_contents")
build_pagination_with_formats(options)
@built = true
end
@@ -64,10 +62,16 @@
def build_pagination_with_formats(options)
div :id => "index_footer" do
build_pagination
div(page_entries_info(options).html_safe, :class => "pagination_information")
- build_download_format_links unless @download_links == false
+
+ if @download_links.is_a?(Array) && !@download_links.empty?
+ build_download_format_links @download_links
+ else
+ build_download_format_links unless @download_links == false
+ end
+
end
end
def build_pagination
options = request.query_parameters.except(:commit, :format)