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_window =
2
- @@empty_field_text =
'-'
- @@association_join_text =
', '
- @@pagination =
true
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
- #no_entries_message ⇒ Object
-
#page_links_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.
-
#show_search_reset ⇒ Object
show a link to reset the search next to filtered message.
Attributes inherited from Base
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.
- #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 |
# 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 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
119 120 121 |
# File 'lib/active_scaffold/config/list.rb', line 119 def always_show_create @always_show_create && @core.actions.include?(:create) end |
#always_show_search ⇒ Object
108 109 110 |
# File 'lib/active_scaffold/config/list.rb', line 108 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
75 76 77 |
# File 'lib/active_scaffold/config/list.rb', line 75 def association_join_text @association_join_text end |
#count_includes ⇒ Object
overwrite the includes used for the count sql query
89 90 91 |
# File 'lib/active_scaffold/config/list.rb', line 89 def count_includes @count_includes end |
#empty_field_text ⇒ Object
what string to use when a field is empty
72 73 74 |
# File 'lib/active_scaffold/config/list.rb', line 72 def empty_field_text @empty_field_text end |
#filtered_message ⇒ Object
103 104 105 |
# File 'lib/active_scaffold/config/list.rb', line 103 def @filtered_message ? @filtered_message : :filtered end |
#hide_nested_column ⇒ Object
125 126 127 |
# File 'lib/active_scaffold/config/list.rb', line 125 def hide_nested_column @hide_nested_column.nil? ? true : @hide_nested_column end |
#label ⇒ Object
93 94 95 |
# File 'lib/active_scaffold/config/list.rb', line 93 def label @label ? as_(@label, :count => 2) : @core.label(:count => 2) end |
#no_entries_message ⇒ Object
98 99 100 |
# File 'lib/active_scaffold/config/list.rb', line 98 def @no_entries_message ? @no_entries_message : :no_entries end |
#page_links_window ⇒ Object
how many page links around current page to show
63 64 65 |
# File 'lib/active_scaffold/config/list.rb', line 63 def page_links_window @page_links_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
69 70 71 |
# File 'lib/active_scaffold/config/list.rb', line 69 def pagination @pagination end |
#per_page ⇒ Object
how many rows to show at once
60 61 62 |
# File 'lib/active_scaffold/config/list.rb', line 60 def per_page @per_page end |
#show_search_reset ⇒ Object
show a link to reset the search next to filtered message
78 79 80 |
# File 'lib/active_scaffold/config/list.rb', line 78 def show_search_reset @show_search_reset end |
Instance Method Details
#columns ⇒ Object
provides access to the list of columns specifically meant for the Table to use
52 53 54 55 |
# File 'lib/active_scaffold/config/list.rb', line 52 def columns self.columns = @core.columns._inheritable unless @columns # lazy evaluation @columns end |
#search_partial ⇒ Object
112 113 114 115 |
# File 'lib/active_scaffold/config/list.rb', line 112 def search_partial return "search" if @core.actions.include?(:search) return "field_search" if @core.actions.include?(:field_search) end |
#sorting ⇒ Object
84 85 86 |
# File 'lib/active_scaffold/config/list.rb', line 84 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’.
81 82 83 |
# File 'lib/active_scaffold/config/list.rb', line 81 def sorting=(val) sorting.set(*val) end |