Module: Workarea::Storefront::PaginationHelper

Defined in:
app/helpers/workarea/storefront/pagination_helper.rb

Instance Method Summary collapse

Instance Method Details

#pagination_data(collection) ⇒ Object



9
10
11
12
13
14
15
# File 'app/helpers/workarea/storefront/pagination_helper.rb', line 9

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

#pagination_path_for(page: 1) ⇒ Object



4
5
6
7
# File 'app/helpers/workarea/storefront/pagination_helper.rb', line 4

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

#show_pagination?(collection) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/helpers/workarea/storefront/pagination_helper.rb', line 17

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