Class: ActiveScaffold::Config::List

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

Defined Under Namespace

Classes: UserSettings

Constant Summary collapse

@@refresh_with_header =
false
@@per_page =
15
2
0
@@empty_field_text =
'-'
@@messages_above_header =
false
@@association_join_text =
', '
@@pagination =
true
@@show_search_reset =
true
ActiveScaffold::DataStructures::ActionLink.new('index', :label => :click_to_reset, :type => :collection, :position => false, :parameters => {:search => ''})
@@wrap_tag =
nil
@@always_show_search =
false
@@always_show_create =
false
@@auto_select_columns =
false

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
23
24
25
26
27
28
29
# 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_inner_window = self.class.page_links_inner_window
  @page_links_outer_window = self.class.page_links_outer_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 = self.class.show_search_reset
  @reset_link = self.class.reset_link.clone
  @wrap_tag = self.class.wrap_tag
  @always_show_search = self.class.always_show_search
  @always_show_create = self.class.always_show_create
  @messages_above_header = self.class.messages_above_header
  @auto_select_columns = self.class.auto_select_columns
  @refresh_with_header = self.class.refresh_with_header
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



178
179
180
# File 'lib/active_scaffold/config/list.rb', line 178

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

#always_show_searchObject



167
168
169
# File 'lib/active_scaffold/config/list.rb', line 167

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

#association_join_textObject

what string to use to join records from plural associations



129
130
131
# File 'lib/active_scaffold/config/list.rb', line 129

def association_join_text
  @association_join_text
end

#auto_select_columnsObject

Enable auto select columns on list, so only columns needed for list columns are selected



199
200
201
# File 'lib/active_scaffold/config/list.rb', line 199

def auto_select_columns
  @auto_select_columns
end

#count_includesObject

overwrite the includes used for the count sql query



148
149
150
# File 'lib/active_scaffold/config/list.rb', line 148

def count_includes
  @count_includes
end

#empty_field_textObject

what string to use when a field is empty



123
124
125
# File 'lib/active_scaffold/config/list.rb', line 123

def empty_field_text
  @empty_field_text
end

#filtered_messageObject



162
163
164
# File 'lib/active_scaffold/config/list.rb', line 162

def filtered_message
  @filtered_message ? @filtered_message : :filtered
end

#hide_nested_columnObject



184
185
186
# File 'lib/active_scaffold/config/list.rb', line 184

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

#labelObject



152
153
154
# File 'lib/active_scaffold/config/list.rb', line 152

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

#messages_above_headerObject

display messages above table header



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

def messages_above_header
  @messages_above_header
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



192
193
194
# File 'lib/active_scaffold/config/list.rb', line 192

def nested_auto_open
  @nested_auto_open
end

#no_entries_messageObject



157
158
159
# File 'lib/active_scaffold/config/list.rb', line 157

def no_entries_message
  @no_entries_message ? @no_entries_message : :no_entries
end

how many page links around current page to show



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

def page_links_inner_window
  @page_links_inner_window
end

how many page links around current page to show



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

def page_links_outer_window
  @page_links_outer_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



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

def pagination
  @pagination
end

#per_pageObject

how many rows to show at once



108
109
110
# File 'lib/active_scaffold/config/list.rb', line 108

def per_page
  @per_page
end

#refresh_with_headerObject

include list header on refresh



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

def refresh_with_header
  @refresh_with_header
end

the ActionLink to reset search



135
136
137
# File 'lib/active_scaffold/config/list.rb', line 135

def reset_link
  @reset_link
end

#show_search_resetObject

show a link to reset the search next to filtered message



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

def show_search_reset
  @show_search_reset
end

#wrap_tagObject

wrap normal cells (not inplace editable columns or with link) with a tag it allows for more css styling



196
197
198
# File 'lib/active_scaffold/config/list.rb', line 196

def wrap_tag
  @wrap_tag
end

Instance Method Details

#columnsObject

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



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

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

#search_partialObject



171
172
173
174
# File 'lib/active_scaffold/config/list.rb', line 171

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

#sortingObject



143
144
145
# File 'lib/active_scaffold/config/list.rb', line 143

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’.



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

def sorting=(val)
  val = [val] if val.is_a? Hash
  sorting.clear
  val.each { |clause| sorting.add *Array(clause).first }
end