app/models/effective/effective_datatable/ajax.rb in effective_datatables-2.6.8 vs app/models/effective/effective_datatable/ajax.rb in effective_datatables-2.6.9
- old
+ new
@@ -8,20 +8,24 @@
# It sends us a list of columns that are different than our table_columns order
# So this method just returns an array of column names, as per ColReorder
def display_table_columns
return nil if params[:columns].blank?
- @display_table_columns ||= params[:columns].each_with_object({}) do |(_, column), retval|
- retval[column[:name]] = table_columns[column[:name]] # Same order as ColReordernow
- retval[column[:name]][:visible] = (column[:visible] == 'true') # As per ColVis
- end
+ @display_table_columns ||= (
+ {}.tap do |retval|
+ params[:columns].each do |_, column|
+ retval[column[:name]] = table_columns[column[:name]] # Same order as ColReordernow
+ retval[column[:name]][:visible] = (column[:visible] == 'true') # As per ColVis
+ end
+ end
+ )
end
def order_name
@order_name ||= begin
if params[:order] && params[:columns]
- order_by_column_index = (params[:order].first[1][:column] rescue '0')
+ order_by_column_index = (params[:order]['0'][:column] rescue '0')
(params[:columns][order_by_column_index] || {})[:name]
elsif @default_order.present?
@default_order.keys.first
end || table_columns.find { |col, opts| opts[:type] != :bulk_actions_column }.first
end
@@ -31,10 +35,10 @@
(table_columns[order_name][:index] || 0) rescue 0
end
def order_direction
@order_direction ||= if params[:order].present?
- params[:order].first[1][:dir] == 'desc' ? :desc : :asc
+ params[:order]['0'][:dir] == 'desc' ? :desc : :asc
elsif @default_order.present?
@default_order.values.first.to_s.downcase == 'desc' ? :desc : :asc
else
:asc
end