Module: Aenea::ActiveAdmin::IndexAsTable::SortableColumns

Included in:
Aenea::ActiveAdmin::IndexAsTable
Defined in:
lib/aenea/active_admin/index_as_table/sortable_columns.rb

Instance Method Summary collapse

Instance Method Details

#sortable_columns(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aenea/active_admin/index_as_table/sortable_columns.rb', line 5

def sortable_columns(options = {})
  unless options[:up_down_only]
    column ''.html_safe do |resource|
      link_to('▲▲'.html_safe, self.send(:"move_to_top_admin_#{resource.class.name.underscore.gsub("/", "_")}_path", resource), :class => 'arrow', title: 'Move to Top') unless resource.first?
    end
  end

  column ''.html_safe do |resource|
    link_to('▲'.html_safe, self.send(:"move_up_admin_#{resource.class.name.underscore.gsub("/", "_")}_path", resource), :class => 'arrow', title: 'Move Up') unless resource.first?
  end

  column ''.html_safe do |resource|
    link_to('▼'.html_safe, self.send(:"move_down_admin_#{resource.class.name.underscore.gsub("/", "_")}_path", resource), :class => 'arrow', title: 'Move Down') unless resource.last?
  end

  unless options[:up_down_only]
    column ''.html_safe do |resource|
      link_to('▼▼'.html_safe, self.send(:"move_to_bottom_admin_#{resource.class.name.underscore.gsub("/", "_")}_path", resource), :class => 'arrow', title: 'Move to Bottom') unless resource.last?
    end
  end
end