Sha256: eddc7b7ff141aef2c1e24a85ea92718239120e85938b6f6a417f1cb25a80fbf3

Contents?: true

Size: 1.04 KB

Versions: 5

Compression:

Stored size: 1.04 KB

Contents

module Storefront
  module TableHelper
    def table_for(*args, &block)
      Storefront::Table.new(self, *args, &block).content
    end
    
    def table_query_row_class
      ["search-row", query_params.except("page", "sort").blank? ? nil : "search-results"].compact.join(" ")
    end
  
    def link_to_sort(title, attribute, options = {})
      sort_param = sort_value(attribute, opposite_sort_direction(attribute))
      link_to title, with_params(request.path, :sort => sort_param), options
    end
  
    def next_page_path(collection)
      with_params(request.path, :page => collection.next_page)
    end
    
    def prev_page_path(collection)
      with_params(request.path, :page => collection.prev_page)
    end
  
    def first_page_path(collection)
      with_params(request.path, :page => 1)
    end
  
    def last_page_path(collection)
      with_params(request.path, :page => collection.last_page)
    end
  
    def current_page_num
      page = params[:page] ? params[:page].to_i : 1
      page = 1 if page < 1
      page
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
storefront-0.3.2 lib/storefront/helpers/table_helper.rb
storefront-0.3.1 lib/storefront/helpers/table_helper.rb
storefront-0.3.0 lib/storefront/helpers/table_helper.rb
storefront-0.2.8 lib/storefront/helpers/table_helper.rb
storefront-0.2.7 lib/storefront/helpers/table_helper.rb