Class: ActiveScaffold::Config::List

Inherits:
Base show all
Defined in:
lib/active_scaffold/config/list.rb

Defined Under Namespace

Classes: UserSettings

Constant Summary collapse

@@per_page =
15
2
@@empty_field_text =
'-'
@@association_join_text =
', '
@@pagination =
true

Instance Attribute Summary collapse

Attributes inherited from Base

#action_group, #user

Instance Method Summary collapse

Methods inherited from Base

#crud_type, #formats, #formats=, inherited

Methods included from ActiveScaffold::Configurable

#configure, #method_missing

Constructor Details

#initialize(core_config) ⇒ List

Returns a new instance of List.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/active_scaffold/config/list.rb', line 5

def initialize(core_config)
  super
  # inherit from global scope
  # full configuration path is: defaults => global table => local table
  @per_page = self.class.per_page
  @page_links_window = self.class.page_links_window
  
  # originates here
  @sorting = ActiveScaffold::DataStructures::Sorting.new(@core.columns)
  @sorting.set_default_sorting(@core.model)

  # inherit from global scope
  @empty_field_text = self.class.empty_field_text
  @association_join_text = self.class.association_join_text
  @pagination = self.class.pagination
  @show_search_reset = true
  @mark_records = self.class.mark_records
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveScaffold::Configurable

Instance Attribute Details

#always_show_createObject



126
127
128
# File 'lib/active_scaffold/config/list.rb', line 126

def always_show_create
  @always_show_create && @core.actions.include?(:create)
end

#always_show_searchObject



115
116
117
# File 'lib/active_scaffold/config/list.rb', line 115

def always_show_search
  @always_show_search && !search_partial.blank?
end

#association_join_textObject

what string to use to join records from plural associations



79
80
81
# File 'lib/active_scaffold/config/list.rb', line 79

def association_join_text
  @association_join_text
end

#count_includesObject

overwrite the includes used for the count sql query



96
97
98
# File 'lib/active_scaffold/config/list.rb', line 96

def count_includes
  @count_includes
end

#empty_field_textObject

what string to use when a field is empty



76
77
78
# File 'lib/active_scaffold/config/list.rb', line 76

def empty_field_text
  @empty_field_text
end

#filtered_messageObject



110
111
112
# File 'lib/active_scaffold/config/list.rb', line 110

def filtered_message
  @filtered_message ? @filtered_message : :filtered
end

#hide_nested_columnObject



132
133
134
# File 'lib/active_scaffold/config/list.rb', line 132

def hide_nested_column
  @hide_nested_column.nil? ? true : @hide_nested_column
end

#labelObject



100
101
102
# File 'lib/active_scaffold/config/list.rb', line 100

def label
  @label ? as_(@label, :count => 2) : @core.label(:count => 2)
end

#mark_recordsObject

Add a checkbox in front of each record to mark them and use them with a batch action later



85
86
87
# File 'lib/active_scaffold/config/list.rb', line 85

def mark_records
  @mark_records
end

#nested_auto_openObject

might be set to open nested_link automatically in view conf.nested.add_link(:players) conf.list.nested_auto_open = => 2 will open nested players view if there are 2 or less records in parent



140
141
142
# File 'lib/active_scaffold/config/list.rb', line 140

def nested_auto_open
  @nested_auto_open
end

#no_entries_messageObject



105
106
107
# File 'lib/active_scaffold/config/list.rb', line 105

def no_entries_message
  @no_entries_message ? @no_entries_message : :no_entries
end

how many page links around current page to show



67
68
69
# File 'lib/active_scaffold/config/list.rb', line 67

def page_links_window
  @page_links_window
end

#paginationObject

What kind of pagination to use:

  • true: The usual pagination

  • :infinite: Treat the source as having an infinite number of pages (i.e. don’t count the records; useful for large tables where counting is slow and we don’t really care anyway)

  • false: Disable pagination



73
74
75
# File 'lib/active_scaffold/config/list.rb', line 73

def pagination
  @pagination
end

#per_pageObject

how many rows to show at once



64
65
66
# File 'lib/active_scaffold/config/list.rb', line 64

def per_page
  @per_page
end

#show_search_resetObject

show a link to reset the search next to filtered message



82
83
84
# File 'lib/active_scaffold/config/list.rb', line 82

def show_search_reset
  @show_search_reset
end

Instance Method Details

#columnsObject

provides access to the list of columns specifically meant for the Table to use



56
57
58
59
# File 'lib/active_scaffold/config/list.rb', line 56

def columns
  self.columns = @core.columns._inheritable unless @columns # lazy evaluation
  @columns
end

#search_partialObject



119
120
121
122
# File 'lib/active_scaffold/config/list.rb', line 119

def search_partial
  return "search" if @core.actions.include?(:search)
  return "field_search" if @core.actions.include?(:field_search)
end

#sortingObject



91
92
93
# File 'lib/active_scaffold/config/list.rb', line 91

def sorting
  @sorting ||= ActiveScaffold::DataStructures::Sorting.new(@core.columns)
end

#sorting=(val) ⇒ Object

the default sorting. should be an array of hashes of => direction, e.g. [=> ‘desc’, => ‘asc’]. to just sort on one column, you can simply provide a hash, though, e.g. => ‘desc’.



88
89
90
# File 'lib/active_scaffold/config/list.rb', line 88

def sorting=(val)
  sorting.set(*val)
end