Class: ActiveScaffold::Config::List
- Defined in:
- lib/active_scaffold/config/list.rb
Defined Under Namespace
Classes: UserSettings
Constant Summary collapse
- @@refresh_with_header =
false- @@per_page =
15- @@page_links_inner_window =
2- @@page_links_outer_window =
0- @@empty_field_text =
'-'- @@messages_above_header =
false- @@association_join_text =
', '- @@pagination =
true- @@auto_pagination =
false- @@show_search_reset =
true- @@show_filter_reset =
true- @@filter_human_message =
false- @@reset_link =
ActiveScaffold::DataStructures::ActionLink.new('index', label: :click_to_reset, type: :collection, position: false, parameters: {search: ''})
- @@reset_filter_link =
ActiveScaffold::DataStructures::ActionLink.new('index', label: :click_to_reset, type: :collection, position: false, dynamic_parameters: -> { clear_filters_params })
- @@wrap_tag =
nil- @@always_show_search =
false- @@always_show_create =
false- @@auto_select_columns =
false- @@calculate_etag =
false
Constants inherited from Base
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.
-
#auto_pagination ⇒ Object
Auto paginate, only can be used with pagination enabled * true: First page will be loaded on first request, next pages will be requested by AJAX until all items are loaded * false: Disable auto pagination.
-
#auto_select_columns ⇒ Object
Enable auto select columns on list, so only columns needed for list columns are selected.
-
#calculate_etag ⇒ Object
Enable ETag calculation (when conditional_get_support is enabled), it requires to load records for page, when is disabled query can be avoided when page is cached in browser order clause will be used for ETag when calculate_etag is disabled, so query for records can be avoided.
-
#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.
-
#filter_human_message ⇒ Object
filter human message you may show the user a humanized applied filters, not the default ones.
- #filtered_message ⇒ Object
-
#filters ⇒ Object
readonly
the filters for this controller.
- #hide_nested_column ⇒ Object
- #label ⇒ Object
-
#messages_above_header ⇒ Object
display messages above table header.
- #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.
-
#refresh_with_header ⇒ Object
include list header on refresh.
-
#reset_filter_link ⇒ Object
readonly
the ActionLink to reset the filters.
-
#reset_link ⇒ Object
readonly
the ActionLink to reset search.
-
#show_filter_reset ⇒ Object
show a link to reset the filter next to filter human message.
-
#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
#action_group, #core, #formats, #user_settings_key
Class Method Summary collapse
Instance Method Summary collapse
- #auto_search_partial ⇒ Object
-
#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, inherited, #model_id, #new_user_settings, #setup_user_setting_key, #user
Methods included from ActiveScaffold::Configurable
#configure, #method_missing, #respond_to_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 30 31 32 33 34 35 |
# 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 @filters = ActiveScaffold::DataStructures::Filters.new @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, @core.model) @sorting.set_default_sorting # inherit from global scope @empty_field_text = self.class.empty_field_text @association_join_text = self.class.association_join_text @pagination = self.class.pagination @auto_pagination = self.class.auto_pagination @show_search_reset = self.class.show_search_reset @show_filter_reset = self.class.show_filter_reset @filter_human_message = self.class. @reset_link = self.class.reset_link.clone @reset_filter_link = self.class.reset_filter_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. @auto_select_columns = self.class.auto_select_columns @refresh_with_header = self.class.refresh_with_header @calculate_etag = self.class.calculate_etag 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
239 240 241 |
# File 'lib/active_scaffold/config/list.rb', line 239 def always_show_create @always_show_create && @core.actions.include?(:create) end |
#always_show_search ⇒ Object
216 217 218 |
# File 'lib/active_scaffold/config/list.rb', line 216 def always_show_search @always_show_search && search_partial.present? end |
#association_join_text ⇒ Object
what string to use to join records from plural associations
162 163 164 |
# File 'lib/active_scaffold/config/list.rb', line 162 def association_join_text @association_join_text end |
#auto_pagination ⇒ Object
Auto paginate, only can be used with pagination enabled
-
true: First page will be loaded on first request, next pages will be requested by AJAX until all items are loaded
-
false: Disable auto pagination
153 154 155 |
# File 'lib/active_scaffold/config/list.rb', line 153 def auto_pagination @auto_pagination end |
#auto_select_columns ⇒ Object
Enable auto select columns on list, so only columns needed for list columns are selected
255 256 257 |
# File 'lib/active_scaffold/config/list.rb', line 255 def auto_select_columns @auto_select_columns end |
#calculate_etag ⇒ Object
Enable ETag calculation (when conditional_get_support is enabled), it requires to load records for page, when is disabled query can be avoided when page is cached in browser order clause will be used for ETag when calculate_etag is disabled, so query for records can be avoided
259 260 261 |
# File 'lib/active_scaffold/config/list.rb', line 259 def calculate_etag @calculate_etag end |
#count_includes ⇒ Object
overwrite the includes used for the count sql query
197 198 199 |
# File 'lib/active_scaffold/config/list.rb', line 197 def count_includes @count_includes end |
#empty_field_text ⇒ Object
what string to use when a field is empty
156 157 158 |
# File 'lib/active_scaffold/config/list.rb', line 156 def empty_field_text @empty_field_text end |
#filter_human_message ⇒ Object
filter human message you may show the user a humanized applied filters, not the default ones
172 173 174 |
# File 'lib/active_scaffold/config/list.rb', line 172 def @filter_human_message end |
#filtered_message ⇒ Object
212 213 214 |
# File 'lib/active_scaffold/config/list.rb', line 212 def @filtered_message || :filtered end |
#filters ⇒ Object (readonly)
the filters for this controller
181 182 183 |
# File 'lib/active_scaffold/config/list.rb', line 181 def filters @filters end |
#hide_nested_column ⇒ Object
246 247 248 |
# File 'lib/active_scaffold/config/list.rb', line 246 def hide_nested_column @hide_nested_column.nil? ? true : @hide_nested_column end |
#label ⇒ Object
202 203 204 |
# File 'lib/active_scaffold/config/list.rb', line 202 def label @label ? as_(@label, count: 2) : @core.label(count: 2) end |
#messages_above_header ⇒ Object
display messages above table header
159 160 161 |
# File 'lib/active_scaffold/config/list.rb', line 159 def @messages_above_header end |
#no_entries_message ⇒ Object
208 209 210 |
# File 'lib/active_scaffold/config/list.rb', line 208 def @no_entries_message || :no_entries end |
#page_links_inner_window ⇒ Object
how many page links around current page to show
139 140 141 |
# File 'lib/active_scaffold/config/list.rb', line 139 def page_links_inner_window @page_links_inner_window end |
#page_links_outer_window ⇒ Object
how many page links around current page to show
142 143 144 |
# File 'lib/active_scaffold/config/list.rb', line 142 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
148 149 150 |
# File 'lib/active_scaffold/config/list.rb', line 148 def pagination @pagination end |
#per_page ⇒ Object
how many rows to show at once
136 137 138 |
# File 'lib/active_scaffold/config/list.rb', line 136 def per_page @per_page end |
#refresh_with_header ⇒ Object
include list header on refresh
133 134 135 |
# File 'lib/active_scaffold/config/list.rb', line 133 def refresh_with_header @refresh_with_header end |
#reset_filter_link ⇒ Object (readonly)
the ActionLink to reset the filters
178 179 180 |
# File 'lib/active_scaffold/config/list.rb', line 178 def reset_filter_link @reset_filter_link end |
#reset_link ⇒ Object (readonly)
the ActionLink to reset search
175 176 177 |
# File 'lib/active_scaffold/config/list.rb', line 175 def reset_link @reset_link end |
#show_filter_reset ⇒ Object
show a link to reset the filter next to filter human message
168 169 170 |
# File 'lib/active_scaffold/config/list.rb', line 168 def show_filter_reset @show_filter_reset end |
#show_search_reset ⇒ Object
show a link to reset the search next to filtered message
165 166 167 |
# File 'lib/active_scaffold/config/list.rb', line 165 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
252 253 254 |
# File 'lib/active_scaffold/config/list.rb', line 252 def wrap_tag @wrap_tag end |
Class Method Details
.filters ⇒ Object
123 124 125 |
# File 'lib/active_scaffold/config/list.rb', line 123 def self.filters ActiveScaffold::DataStructures::Filters end |
Instance Method Details
#auto_search_partial ⇒ Object
228 229 230 231 232 233 234 |
# File 'lib/active_scaffold/config/list.rb', line 228 def auto_search_partial if @core.actions.include?(:search) 'search' elsif @core.actions.include?(:field_search) 'field_search' end end |
#search_partial ⇒ Object
220 221 222 223 224 225 226 |
# File 'lib/active_scaffold/config/list.rb', line 220 def search_partial if @always_show_search == true auto_search_partial elsif @core.actions.include? @always_show_search @always_show_search.to_s end end |
#sorting ⇒ Object
192 193 194 |
# File 'lib/active_scaffold/config/list.rb', line 192 def sorting @sorting ||= ActiveScaffold::DataStructures::Sorting.new(@core.columns, @core.model) end |
#sorting=(val) ⇒ Object
the default sorting. should be a hash of => direction, e.g. ‘desc’, b: ‘asc’. for backwards compatibility, it may be an array of hashes of => direction, e.g. [‘desc’, ‘asc’]. to just sort on one column, you can simply provide a hash, e.g. ‘desc’.
187 188 189 190 |
# File 'lib/active_scaffold/config/list.rb', line 187 def sorting=(val) val = [val] if val.is_a? Hash sorting.set(*val) end |