Class: ActiveScaffold::Config::List
- Defined in:
- lib/active_scaffold/config/list.rb
Defined Under Namespace
Classes: UserSettings
Constant Summary collapse
- @@per_page =
15
- @@page_links_inner_window =
2
- @@page_links_outer_window =
0
- @@empty_field_text =
'-'
- @@association_join_text =
', '
- @@pagination =
true
- @@show_search_reset =
true
- @@reset_link =
ActiveScaffold::DataStructures::ActionLink.new('index', :label => :click_to_reset, :type => :collection, :position => false)
- @@wrap_tag =
nil
- @@always_show_search =
false
- @@always_show_create =
false
Instance Attribute Summary collapse
- #always_show_create ⇒ Object
- #always_show_search ⇒ Object
-
#association_join_text ⇒ Object
what string to use to join records from plural associations.
-
#count_includes ⇒ Object
overwrite the includes used for the count sql query.
-
#empty_field_text ⇒ Object
what string to use when a field is empty.
- #filtered_message ⇒ Object
- #hide_nested_column ⇒ Object
- #label ⇒ Object
-
#nested_auto_open ⇒ Object
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.
- #no_entries_message ⇒ Object
-
#page_links_inner_window ⇒ Object
how many page links around current page to show.
-
#page_links_outer_window ⇒ Object
how many page links around current page to show.
-
#pagination ⇒ Object
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.
-
#per_page ⇒ Object
how many rows to show at once.
-
#reset_link ⇒ Object
readonly
the ActionLink to reset search.
-
#show_search_reset ⇒ Object
show a link to reset the search next to filtered message.
-
#wrap_tag ⇒ Object
wrap normal cells (not inplace editable columns or with link) with a tag it allows for more css styling.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#columns ⇒ Object
provides access to the list of columns specifically meant for the Table to use.
-
#initialize(core_config) ⇒ List
constructor
A new instance of List.
- #page_links_window=(value) ⇒ Object
- #search_partial ⇒ Object
- #sorting ⇒ Object
-
#sorting=(val) ⇒ Object
the default sorting.
Methods inherited from Base
#crud_type, #formats, #formats=, inherited
Methods included from ActiveScaffold::Configurable
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 |
# 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 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveScaffold::Configurable
Instance Attribute Details
#always_show_create ⇒ Object
169 170 171 |
# File 'lib/active_scaffold/config/list.rb', line 169 def always_show_create @always_show_create && @core.actions.include?(:create) end |
#always_show_search ⇒ Object
158 159 160 |
# File 'lib/active_scaffold/config/list.rb', line 158 def always_show_search @always_show_search && !search_partial.blank? end |
#association_join_text ⇒ Object
what string to use to join records from plural associations
120 121 122 |
# File 'lib/active_scaffold/config/list.rb', line 120 def association_join_text @association_join_text end |
#count_includes ⇒ Object
overwrite the includes used for the count sql query
139 140 141 |
# File 'lib/active_scaffold/config/list.rb', line 139 def count_includes @count_includes end |
#empty_field_text ⇒ Object
what string to use when a field is empty
117 118 119 |
# File 'lib/active_scaffold/config/list.rb', line 117 def empty_field_text @empty_field_text end |
#filtered_message ⇒ Object
153 154 155 |
# File 'lib/active_scaffold/config/list.rb', line 153 def @filtered_message ? @filtered_message : :filtered end |
#hide_nested_column ⇒ Object
175 176 177 |
# File 'lib/active_scaffold/config/list.rb', line 175 def hide_nested_column @hide_nested_column.nil? ? true : @hide_nested_column end |
#label ⇒ Object
143 144 145 |
# File 'lib/active_scaffold/config/list.rb', line 143 def label @label ? as_(@label, :count => 2) : @core.label(:count => 2) end |
#nested_auto_open ⇒ Object
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
183 184 185 |
# File 'lib/active_scaffold/config/list.rb', line 183 def nested_auto_open @nested_auto_open end |
#no_entries_message ⇒ Object
148 149 150 |
# File 'lib/active_scaffold/config/list.rb', line 148 def @no_entries_message ? @no_entries_message : :no_entries end |
#page_links_inner_window ⇒ Object
how many page links around current page to show
100 101 102 |
# File 'lib/active_scaffold/config/list.rb', line 100 def page_links_inner_window @page_links_inner_window end |
#page_links_outer_window ⇒ Object
how many page links around current page to show
103 104 105 |
# File 'lib/active_scaffold/config/list.rb', line 103 def page_links_outer_window @page_links_outer_window end |
#pagination ⇒ Object
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
114 115 116 |
# File 'lib/active_scaffold/config/list.rb', line 114 def pagination @pagination end |
#per_page ⇒ Object
how many rows to show at once
97 98 99 |
# File 'lib/active_scaffold/config/list.rb', line 97 def per_page @per_page end |
#reset_link ⇒ Object (readonly)
the ActionLink to reset search
126 127 128 |
# File 'lib/active_scaffold/config/list.rb', line 126 def reset_link @reset_link end |
#show_search_reset ⇒ Object
show a link to reset the search next to filtered message
123 124 125 |
# File 'lib/active_scaffold/config/list.rb', line 123 def show_search_reset @show_search_reset end |
#wrap_tag ⇒ Object
wrap normal cells (not inplace editable columns or with link) with a tag it allows for more css styling
187 188 189 |
# File 'lib/active_scaffold/config/list.rb', line 187 def wrap_tag @wrap_tag end |
Class Method Details
.page_links_window=(value) ⇒ Object
43 44 45 46 |
# File 'lib/active_scaffold/config/list.rb', line 43 def page_links_window=(value) ActiveSupport::Deprecation.warn("Use page_links_inner_window", caller(1)) self.page_links_inner_window = value end |
Instance Method Details
#columns ⇒ Object
provides access to the list of columns specifically meant for the Table to use
89 90 91 92 |
# File 'lib/active_scaffold/config/list.rb', line 89 def columns self.columns = @core.columns._inheritable unless @columns # lazy evaluation @columns end |
#page_links_window=(value) ⇒ Object
105 106 107 108 |
# File 'lib/active_scaffold/config/list.rb', line 105 def page_links_window=(value) ActiveSupport::Deprecation.warn("Use page_links_inner_window", caller(1)) self.page_links_inner_window = value end |
#search_partial ⇒ Object
162 163 164 165 |
# File 'lib/active_scaffold/config/list.rb', line 162 def search_partial return "search" if @core.actions.include?(:search) return "field_search" if @core.actions.include?(:field_search) end |
#sorting ⇒ Object
134 135 136 |
# File 'lib/active_scaffold/config/list.rb', line 134 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’.
129 130 131 132 133 |
# File 'lib/active_scaffold/config/list.rb', line 129 def sorting=(val) val = [val] if val.is_a? Hash sorting.clear val.each { |clause| sorting.add *Array(clause).first } end |