Module: SortableTable::App::Helpers::ApplicationHelper::InstanceMethods
- Defined in:
- lib/sortable_table/app/helpers/application_helper.rb
Instance Method Summary (collapse)
- - (Object) link_sort_order(opts)
- - (Boolean) re_sort?(opts)
- - (Object) reverse_order(order)
- - (Object) sortable_table_header(opts = {})
- - (Object) sortable_table_header_class(opts)
- - (Object) sortable_table_header_classes(opts)
- - (Object) sortable_url(opts)
- - (Boolean) sorting_default?(opts)
Instance Method Details
- (Object) link_sort_order(opts)
52 53 54 55 56 57 58 |
# File 'lib/sortable_table/app/helpers/application_helper.rb', line 52 def link_sort_order(opts) if re_sort? opts reverse_order params[:order] else reverse_order sortable_table_direction end end |
- (Boolean) re_sort?(opts)
40 41 42 |
# File 'lib/sortable_table/app/helpers/application_helper.rb', line 40 def re_sort?(opts) params[:sort] == opts[:sort] end |
- (Object) reverse_order(order)
44 45 46 |
# File 'lib/sortable_table/app/helpers/application_helper.rb', line 44 def reverse_order(order) order == 'ascending' ? 'descending' : 'ascending' end |
- (Object) sortable_table_header(opts = {})
13 14 15 16 17 18 19 20 21 |
# File 'lib/sortable_table/app/helpers/application_helper.rb', line 13 def sortable_table_header(opts = {}) raise ArgumentError if opts[:name].nil? || opts[:sort].nil? anchor = opts[:anchor].blank? ? "" : "##{opts[:anchor]}" content_tag :th, link_to(opts[:name], sortable_url(opts) + anchor, :title => opts[:title]), :class => sortable_table_header_classes(opts) end |
- (Object) sortable_table_header_class(opts)
30 31 32 33 34 |
# File 'lib/sortable_table/app/helpers/application_helper.rb', line 30 def sortable_table_header_class(opts) if re_sort?(opts) || sorting_default?(opts) sortable_table_direction end end |
- (Object) sortable_table_header_classes(opts)
23 24 25 26 27 28 |
# File 'lib/sortable_table/app/helpers/application_helper.rb', line 23 def sortable_table_header_classes(opts) class_names = [] class_names << sortable_table_header_class(opts) class_names << opts[:class] class_names.compact.blank? ? nil : class_names.compact.join(" ") end |
- (Object) sortable_url(opts)
48 49 50 |
# File 'lib/sortable_table/app/helpers/application_helper.rb', line 48 def sortable_url(opts) url_for(params.merge(:sort => opts[:sort], :order => link_sort_order(opts), :page => 1)) end |
- (Boolean) sorting_default?(opts)
36 37 38 |
# File 'lib/sortable_table/app/helpers/application_helper.rb', line 36 def sorting_default?(opts) params[:sort].nil? && opts[:sort] == default_sort_column end |