fix merge mistake
This commit is contained in:
parent
c2b6815559
commit
aa99b78c1b
|
@ -42,38 +42,38 @@ module Kaminari
|
|||
link_to_unless scope.last_page?, name, params.merge(param_name => (scope.current_page + 1)), options.reverse_merge(:rel => 'next') do
|
||||
block.call if block
|
||||
end
|
||||
end
|
||||
|
||||
# Renders a helpful message with numbers of displayed vs. total entries.
|
||||
# Ported from mislav/will_paginate
|
||||
#
|
||||
# ==== Examples
|
||||
# Basic usage:
|
||||
#
|
||||
# <%= page_entries_info @posts %>
|
||||
# #-> Displaying posts 6 - 10 of 26 in total
|
||||
#
|
||||
# By default, the message will use the humanized class name of objects
|
||||
# in collection: for instance, "project types" for ProjectType models.
|
||||
# Override this with the <tt>:entry_name</tt> parameter:
|
||||
#
|
||||
# <%= page_entries_info @posts, :entry_name => 'item' %>
|
||||
# #-> Displaying items 6 - 10 of 26 in total
|
||||
def page_entries_info(collection, options = {})
|
||||
entry_name = options[:entry_name] || (collection.empty?? 'entry' : collection.first.class.name.underscore.sub('_', ' '))
|
||||
if collection.num_pages < 2
|
||||
case collection.total_count
|
||||
when 0; "No #{entry_name.pluralize} found"
|
||||
when 1; "Displaying <b>1</b> #{entry_name}"
|
||||
else; "Displaying <b>all #{collection.total_count}</b> #{entry_name.pluralize}"
|
||||
end
|
||||
else
|
||||
offset = (collection.current_page - 1) * collection.limit_value
|
||||
%{Displaying #{entry_name.pluralize} <b>%d - %d</b> of <b>%d</b> in total} % [
|
||||
offset + 1,
|
||||
offset + collection.count,
|
||||
collection.total_count
|
||||
]
|
||||
# Renders a helpful message with numbers of displayed vs. total entries.
|
||||
# Ported from mislav/will_paginate
|
||||
#
|
||||
# ==== Examples
|
||||
# Basic usage:
|
||||
#
|
||||
# <%= page_entries_info @posts %>
|
||||
# #-> Displaying posts 6 - 10 of 26 in total
|
||||
#
|
||||
# By default, the message will use the humanized class name of objects
|
||||
# in collection: for instance, "project types" for ProjectType models.
|
||||
# Override this with the <tt>:entry_name</tt> parameter:
|
||||
#
|
||||
# <%= page_entries_info @posts, :entry_name => 'item' %>
|
||||
# #-> Displaying items 6 - 10 of 26 in total
|
||||
def page_entries_info(collection, options = {})
|
||||
entry_name = options[:entry_name] || (collection.empty?? 'entry' : collection.first.class.name.underscore.sub('_', ' '))
|
||||
if collection.num_pages < 2
|
||||
case collection.total_count
|
||||
when 0; "No #{entry_name.pluralize} found"
|
||||
when 1; "Displaying <b>1</b> #{entry_name}"
|
||||
else; "Displaying <b>all #{collection.total_count}</b> #{entry_name.pluralize}"
|
||||
end
|
||||
else
|
||||
offset = (collection.current_page - 1) * collection.limit_value
|
||||
%{Displaying #{entry_name.pluralize} <b>%d - %d</b> of <b>%d</b> in total} % [
|
||||
offset + 1,
|
||||
offset + collection.count,
|
||||
collection.total_count
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue