Module: AbAdmin::Views::ManagerHelpers

Defined in:
lib/ab_admin/views/manager_helpers.rb

Constant Summary collapse

INDEX_VIEW_ICONS =
{table: 'list', tree: 'move', grid: 'th'}

Instance Method Summary collapse

Instance Method Details

#action_item_admin_path(name, record = nil) ⇒ Object


27
28
29
30
31
32
33
34
35
# File 'lib/ab_admin/views/manager_helpers.rb', line 27

def action_item_admin_path(name, record=nil)
  custom_action = manager.custom_action_for(name, self)
  if custom_action.collection?
    admin_collection_action_path(model_name: resource_collection_name, custom_action: custom_action.name)
  else
    record ||= resource
    admin_member_action_path(model_name: resource_collection_name, id: record.id, custom_action: custom_action.name)
  end
end

#form_builderObject


15
16
17
# File 'lib/ab_admin/views/manager_helpers.rb', line 15

def form_builder
  manager.form ||= ::AbAdmin::Config::Form.default_for_model(resource_class, skip: [:id, :created_at, :updated_at, :lft, :rgt, :depth])
end

37
38
39
40
41
# File 'lib/ab_admin/views/manager_helpers.rb', line 37

def index_view_link(index_view)
  options = {class: "btn #{('active' if current_index_view == index_view)}", title: t("admin.index_view.#{index_view}")}
  url = url_for(index_view: index_view)
  link_to icon(INDEX_VIEW_ICONS[index_view.to_sym]), url, options
end

19
20
21
# File 'lib/ab_admin/views/manager_helpers.rb', line 19

def modal_form_builder
  manager.modal_form ||= ::AbAdmin::Config::ModalForm.default_for_model(resource_class, skip: [:id, :created_at, :updated_at, :lft, :rgt, :depth])
end

#search_builderObject


11
12
13
# File 'lib/ab_admin/views/manager_helpers.rb', line 11

def search_builder
  manager.search ||= ::AbAdmin::Config::Search.default_for_model(resource_class)
end

#show_builderObject


23
24
25
# File 'lib/ab_admin/views/manager_helpers.rb', line 23

def show_builder
  manager.show ||= ::AbAdmin::Config::Show.default_for_model(resource_class)
end

#table_builderObject


7
8
9
# File 'lib/ab_admin/views/manager_helpers.rb', line 7

def table_builder
  manager.table ||= ::AbAdmin::Config::Table.default_for_model(resource_class)
end