Module: ActiveAdmin::SortableTable::HandleColumn

Defined in:
lib/active_admin/sortable_table/handle_column.rb

Overview

Adds ‘handle_column` method to `TableFor` dsl.

Examples:

on index page

index do
  handle_column
  id_column
  # other columns...
end

table_for

table_for c.collection_memberships do
  handle_column
  # other columns...
end

Constant Summary collapse

DEFAULT_OPTIONS =
{
  move_to_top_url: ->(resource) { url_for([:move_to_top, :admin, resource]) },
  move_to_top_handle: '⤒'.html_safe,
  show_move_to_top_handle: ->(resource) { !resource.first? },
  sort_url: ->(resource) { url_for([:sort, :admin, resource]) },
  sort_handle: '☰'.html_safe
}

Instance Method Summary collapse

Instance Method Details

#handle_column(arguments = {}) ⇒ Object

Parameters:

  • arguments (Hash) (defaults to: {})

Options Hash (arguments):

  • :sort_url (Symbol, Proc, String)
  • :sort_handle (Symbol, Proc, String)
  • :move_to_top_url (Symbol, Proc, String)
  • :move_to_top_handle (Symbol, Proc, String)


35
36
37
38
39
40
41
42
43
# File 'lib/active_admin/sortable_table/handle_column.rb', line 35

def handle_column(arguments = {})
  defined_options = Uber::Options.new(DEFAULT_OPTIONS.merge(arguments))

  column '', class: 'activeadmin_sortable_table' do |resource|
    options = defined_options.evaluate(self, resource)

    sort_handle(options, resource.send(resource.position_column)) + move_to_top_handle(options)
  end
end