Sha256: 2f81975919dbece9c47e0f7615e21a5bdf7bd37becc0eb48db86b80e5d9b9c59

Contents?: true

Size: 1.13 KB

Versions: 25

Compression:

Stored size: 1.13 KB

Contents

module Trestle
  module PaginationHelper
    # Custom version of Kaminari's page_entries_info helper to use a
    # Trestle-scoped I18n key and add a delimiter to the total count.
    def page_entries_info(collection, options = {})
      entry_name = options[:entry_name] || "entry"
      entry_name = entry_name.pluralize unless collection.total_count == 1

      if collection.total_pages < 2
        t('trestle.helpers.page_entries_info.one_page.display_entries', entry_name: entry_name, count: collection.total_count, default: "Displaying <strong>all %{count}</strong> %{entry_name}")
      else
        first = number_with_delimiter(collection.offset_value + 1)
        last  = number_with_delimiter((sum = collection.offset_value + collection.limit_value) > collection.total_count ? collection.total_count : sum)
        total = number_with_delimiter(collection.total_count)

        t('trestle.helpers.page_entries_info.more_pages.display_entries', entry_name: entry_name, first: first, last: last, total: total, default: "Displaying %{entry_name} <strong>%{first}&nbsp;-&nbsp;%{last}</strong> of <b>%{total}</b>")
      end.html_safe
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
trestle-0.10.0 app/helpers/trestle/pagination_helper.rb
trestle-0.10.0.pre2 app/helpers/trestle/pagination_helper.rb
trestle-0.10.0.pre app/helpers/trestle/pagination_helper.rb
trestle-0.9.8 app/helpers/trestle/pagination_helper.rb
trestle-0.9.7 app/helpers/trestle/pagination_helper.rb
trestle-0.9.6 app/helpers/trestle/pagination_helper.rb
trestle-0.9.5 app/helpers/trestle/pagination_helper.rb
trestle-0.9.4 app/helpers/trestle/pagination_helper.rb
trestle-0.9.3 app/helpers/trestle/pagination_helper.rb
trestle-0.9.2 app/helpers/trestle/pagination_helper.rb
trestle-0.9.1 app/helpers/trestle/pagination_helper.rb
trestle-0.9.0 app/helpers/trestle/pagination_helper.rb
trestle-0.8.13 app/helpers/trestle/pagination_helper.rb
trestle-0.8.12 app/helpers/trestle/pagination_helper.rb
trestle-0.8.11 app/helpers/trestle/pagination_helper.rb
trestle-0.8.10 app/helpers/trestle/pagination_helper.rb
trestle-0.8.9 app/helpers/trestle/pagination_helper.rb
trestle-0.8.8 app/helpers/trestle/pagination_helper.rb
trestle-0.8.7 app/helpers/trestle/pagination_helper.rb
trestle-0.8.6 app/helpers/trestle/pagination_helper.rb