Class: AdminWidgets::ListWidget::Header
- Inherits:
-
Object
- Object
- AdminWidgets::ListWidget::Header
- Extended by:
- Delegation
- Defined in:
- lib/admin_widgets/list_widget.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
- #css_class ⇒ Object
- #current_sort_field? ⇒ Boolean
-
#initialize(parent, field) ⇒ Header
constructor
A new instance of Header.
- #label ⇒ Object
- #next_sort_direction ⇒ Object
- #sort_field ⇒ Object
- #sort_params ⇒ Object
- #url ⇒ Object
Methods included from Delegation
Constructor Details
#initialize(parent, field) ⇒ Header
Returns a new instance of Header.
160 161 162 |
# File 'lib/admin_widgets/list_widget.rb', line 160 def initialize(parent, field) @parent, @field = parent, field end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
158 159 160 |
# File 'lib/admin_widgets/list_widget.rb', line 158 def field @field end |
#parent ⇒ Object
Returns the value of attribute parent.
158 159 160 |
# File 'lib/admin_widgets/list_widget.rb', line 158 def parent @parent end |
Instance Method Details
#css_class ⇒ Object
204 205 206 |
# File 'lib/admin_widgets/list_widget.rb', line 204 def css_class sort_direction if current_sort_field? end |
#current_sort_field? ⇒ Boolean
177 178 179 |
# File 'lib/admin_widgets/list_widget.rb', line 177 def current_sort_field? helper.params[:sort_field] == sort_field.to_s end |
#label ⇒ Object
196 197 198 |
# File 'lib/admin_widgets/list_widget.rb', line 196 def label resource_class.human_attribute_name(field.name) end |
#next_sort_direction ⇒ Object
181 182 183 |
# File 'lib/admin_widgets/list_widget.rb', line 181 def next_sort_direction (current_sort_field? && sort_direction == 'asc') ? 'desc' : 'asc' end |
#sort_field ⇒ Object
173 174 175 |
# File 'lib/admin_widgets/list_widget.rb', line 173 def sort_field field.name end |
#sort_params ⇒ Object
185 186 187 188 189 190 191 192 193 194 |
# File 'lib/admin_widgets/list_widget.rb', line 185 def sort_params { :sort_field => sort_field, :sort_direction => next_sort_direction, :per_page => per_page, :page => page, :where => where, :scope => scope } end |
#url ⇒ Object
200 201 202 |
# File 'lib/admin_widgets/list_widget.rb', line 200 def url helper.collection_path(sort_params) end |