module Mincer::ActionView::SortHelper
Public Instance Methods
opposite_order_for(collection, attribute)
click to toggle source
# File lib/mincer/action_view/sort_helper.rb, line 12 def opposite_order_for(collection, attribute) return nil unless collection.sort_attribute == attribute.to_s if collection.sort_order.to_s.downcase == 'asc' 'desc' elsif collection.sort_order.to_s.downcase == 'desc' 'asc' else 'asc' end end
sort_class_for(collection, attribute)
click to toggle source
Returns chevron class, if attribute is the one that was used for sorting
collection
- instance of QueryObject attribute
- Attribute that will be used to sort table
# File lib/mincer/action_view/sort_helper.rb, line 28 def sort_class_for(collection, attribute) return nil unless collection.sort_attribute == attribute.to_s if collection.sort_order.downcase == 'asc' ::Mincer.config.sorting.asc_class elsif collection.sort_order.downcase == 'desc' ::Mincer.config.sorting.desc_class else '' end end
sort_url_for(collection, attribute, permitted_params = params)
click to toggle source
Returns sorting URL for collection and attribute
collection
- instance of QueryObject attribute
- Attribute that will be used to sort table
# File lib/mincer/action_view/sort_helper.rb, line 8 def sort_url_for(collection, attribute, permitted_params = params) url_for(permitted_params.merge(:sort => attribute, :order => opposite_order_for(collection, attribute))) end