lib/table_for/base.rb in table-for-3.6.1 vs lib/table_for/base.rb in table-for-3.6.2
- old
+ new
@@ -56,11 +56,11 @@
def header_column_html(column, options={})
header_column_html = call_each_hash_value_with_params(options[:header_column_html], column)
if options[:sortable]
order = options[:order] ? options[:order].to_s : column.name.to_s
- sort_modes = TableFor.config.sort_modes
+ sort_modes = options[:sort_modes].presence || TableFor.config.sort_modes
current_sort_mode = (view.params[:order] != order || view.params[:sort_mode].blank?) ? nil : view.params[:sort_mode]
current_sort_mode = sort_modes[sort_modes.index(current_sort_mode.to_sym)] rescue nil if current_sort_mode
sort_class = "sorting#{"_#{current_sort_mode}" if current_sort_mode}"
header_column_html[:class] = (header_column_html[:class] ? "#{header_column_html[:class]} #{sort_class}" : sort_class)
@@ -103,24 +103,24 @@
def header_sort_link(column, options={}, &block)
if options[:sortable] && (options[:header] || !column.anonymous)
order = options[:order] ? options[:order].to_s : column.name.to_s
- sort_modes = TableFor.config.sort_modes
+ sort_modes = options[:sort_modes].presence || TableFor.config.sort_modes
current_sort_mode = (view.params[:order] != order || view.params[:sort_mode].blank?) ? nil : view.params[:sort_mode]
next_sort_mode_index = sort_modes.index(current_sort_mode.to_sym) + 1 rescue 0
if next_sort_mode_index == sort_modes.length
next_sort_mode = nil
else
next_sort_mode = sort_modes[next_sort_mode_index]
end
parameters = view.params.merge(:order => order, :sort_mode => next_sort_mode)
+ parameters.delete(:action)
+ parameters.delete(:controller)
if parameters.respond_to?(:to_unsafe_h)
parameters = parameters.to_unsafe_h
end
- parameters.delete(:action)
- parameters.delete(:controller)
url = options[:sort_url] ? options[:sort_url] : ""
view.link_to view.capture(self, &block), "#{url}?#{parameters.to_query}"
else
view.capture(self, &block)
end