Sha256: 8fbfa85144a6294755d825208300fc094a00eeafd4ace380aa085f7bbc6ac0bd

Contents?: true

Size: 627 Bytes

Versions: 62

Compression:

Stored size: 627 Bytes

Contents

module Workarea
  module Storefront
    module PaginationHelper
      def pagination_path_for(page: 1)
        new_query_string_params = request.query_parameters.merge(page: page)
        "#{request.path}?#{new_query_string_params.to_query}"
      end

      def pagination_data(collection)
        {
          currentPage: collection.current_page,
          lastPage: collection.last_page?,
          nextPageUrl: pagination_path_for(page: collection.current_page + 1)
        }.to_json
      end

      def show_pagination?(collection)
        collection.total_pages > 1 && !collection.last_page?
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-storefront-3.4.13 app/helpers/workarea/storefront/pagination_helper.rb
workarea-storefront-3.4.12 app/helpers/workarea/storefront/pagination_helper.rb