Class: AdminAssistant::Index
- Inherits:
-
Object
- Object
- AdminAssistant::Index
show all
- Defined in:
- lib/admin_assistant/index.rb
Defined Under Namespace
Classes: RecordFinder, View
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(admin_assistant, url_params = {}, controller_methods = {}) ⇒ Index
Returns a new instance of Index.
7
8
9
10
|
# File 'lib/admin_assistant/index.rb', line 7
def initialize(admin_assistant, url_params = {}, controller_methods = {})
@admin_assistant, @url_params, @controller_methods =
admin_assistant, url_params, controller_methods
end
|
Instance Attribute Details
#admin_assistant ⇒ Object
Returns the value of attribute admin_assistant.
5
6
7
|
# File 'lib/admin_assistant/index.rb', line 5
def admin_assistant
@admin_assistant
end
|
#controller_methods ⇒ Object
Returns the value of attribute controller_methods.
5
6
7
|
# File 'lib/admin_assistant/index.rb', line 5
def controller_methods
@controller_methods
end
|
#url_params ⇒ Object
Returns the value of attribute url_params.
5
6
7
|
# File 'lib/admin_assistant/index.rb', line 5
def url_params
@url_params
end
|
Instance Method Details
#belongs_to_columns ⇒ Object
12
13
14
|
# File 'lib/admin_assistant/index.rb', line 12
def belongs_to_columns
@admin_assistant.accumulate_belongs_to_columns column_names
end
|
#column_names ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/admin_assistant/index.rb', line 16
def column_names
if settings.column_names
settings.column_names
else
model_class.columns.map(&:name).reject { |n|
%w(created_at updated_at).include?(n)
}
end
end
|
#columns ⇒ Object
26
27
28
|
# File 'lib/admin_assistant/index.rb', line 26
def columns
@admin_assistant.accumulate_columns column_names
end
|
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/admin_assistant/index.rb', line 30
def hidden_fields_for_search_form
if @admin_assistant.search_settings.include_params_in_form
@url_params.reject do |name,value|
name=="commit" or name=="search" or name=="action" or
name=="controller"
end
else
[]
end
end
|
#model_class ⇒ Object
41
42
43
|
# File 'lib/admin_assistant/index.rb', line 41
def model_class
@admin_assistant.model_class
end
|
#records ⇒ Object
45
46
47
|
# File 'lib/admin_assistant/index.rb', line 45
def records
@records ||= RecordFinder.new(self).run
end
|
#search ⇒ Object
49
50
51
52
53
|
# File 'lib/admin_assistant/index.rb', line 49
def search
@search ||= AdminAssistant::Search.new(
@admin_assistant, @url_params['search']
)
end
|
#search_requested? ⇒ Boolean
55
56
57
|
# File 'lib/admin_assistant/index.rb', line 55
def search_requested?
!@url_params['search'].blank?
end
|
#settings ⇒ Object
59
60
61
|
# File 'lib/admin_assistant/index.rb', line 59
def settings
@admin_assistant.index_settings
end
|
#sort ⇒ Object
63
64
65
66
|
# File 'lib/admin_assistant/index.rb', line 63
def sort
@url_params[:sort] ||
(settings.sort_by.to_s if settings.sort_by.is_a?(Symbol))
end
|
#sort_order ⇒ Object
68
69
70
|
# File 'lib/admin_assistant/index.rb', line 68
def sort_order
@url_params[:sort_order] || 'asc'
end
|
#view(action_view) ⇒ Object
72
73
74
|
# File 'lib/admin_assistant/index.rb', line 72
def view(action_view)
@view ||= View.new(self, action_view, @admin_assistant)
end
|