Class: ActiveAdmin::Views::IndexAsDynamicTable

Inherits:
IndexAsTable
  • Object
show all
Defined in:
lib/activeadmin_dynamic_table/views/index_as_dynamic_table.rb

Defined Under Namespace

Classes: IndexDynamicTableFor

Instance Method Summary collapse

Instance Method Details

#build(page_presenter, collection) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/activeadmin_dynamic_table/views/index_as_dynamic_table.rb', line 100

def build(page_presenter, collection)
  settings = ActiveadminDynamicTable::SettingStringParser.new(params[:columns])
  @configurator = ActiveadminDynamicTable::Configurator.new(self, settings.parse)

  table_options = {
    id: "index_table_#{active_admin_config.resource_name.plural}",
    sortable: true,
    class: "index_table index dynamic_table",
    i18n: active_admin_config.resource_class,
    paginator: page_presenter[:paginator] != false,
    row_class: page_presenter[:row_class]
  }

  table_for collection, table_options do |t|
    table_config_block = page_presenter.block || default_table
    instance_exec(t, &table_config_block)

    apply_configuration
  end

  columns_list
end

#register_actions(*args, &block) ⇒ Object



139
140
141
# File 'lib/activeadmin_dynamic_table/views/index_as_dynamic_table.rb', line 139

def register_actions(*args, &block)
  @configurator.register_column(:actions, *args, &block)
end

#register_column(*args, &block) ⇒ Object



127
128
129
# File 'lib/activeadmin_dynamic_table/views/index_as_dynamic_table.rb', line 127

def register_column(*args, &block)
  @configurator.register_column(:column, *args, &block)
end

#register_id_column(*args, &block) ⇒ Object



131
132
133
# File 'lib/activeadmin_dynamic_table/views/index_as_dynamic_table.rb', line 131

def register_id_column(*args, &block)
  @configurator.register_column(:id_column, *args, &block)
end

#register_index_column(*args, &block) ⇒ Object



135
136
137
# File 'lib/activeadmin_dynamic_table/views/index_as_dynamic_table.rb', line 135

def register_index_column(*args, &block)
  @configurator.register_column(:index_column, *args, &block)
end

#table_for(*args, &block) ⇒ Object



123
124
125
# File 'lib/activeadmin_dynamic_table/views/index_as_dynamic_table.rb', line 123

def table_for(*args, &block)
  insert_tag IndexDynamicTableFor, @configurator, *args, &block
end