Class: Acts::DataTable::SortableColumns::Renderers::Default
- Inherits:
-
Object
- Object
- Acts::DataTable::SortableColumns::Renderers::Default
- Defined in:
- lib/acts_as_data_table/sortable_columns/renderers/default.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#caption ⇒ String
The column header’s caption.
-
#caption_link ⇒ String
A link to toggle a column.
-
#direction_indicator ⇒ String
An indicator about the sorting direction for the current column.
-
#direction_link ⇒ String
A link to change the sorting direction for an already active column.
-
#initialize(sortable, action_view) ⇒ Default
constructor
A new instance of Default.
-
#to_html ⇒ String
Generates the actual HTML (= caption and direction links) to be embedded into the view.
Constructor Details
#initialize(sortable, action_view) ⇒ Default
Returns a new instance of Default.
19 20 21 22 |
# File 'lib/acts_as_data_table/sortable_columns/renderers/default.rb', line 19 def initialize(sortable, action_view) @action_view = action_view @sortable = sortable end |
Instance Method Details
#caption ⇒ String
Returns The column header’s caption.
35 36 37 |
# File 'lib/acts_as_data_table/sortable_columns/renderers/default.rb', line 35 def @sortable. end |
#caption_link ⇒ String
Returns a link to toggle a column.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/acts_as_data_table/sortable_columns/renderers/default.rb', line 53 def = @sortable..clone ['data-init'] = 'sortable-column' ['data-remote'] = @sortable.remote ['data-url-toggle'] = @sortable.urls.toggle ['data-url-set-base'] = @sortable.urls.set_base ['data-url-change-direction'] = @sortable.urls.change_direction ['data-active'] = 'true' if @sortable.active @action_view.link_to(@sortable., '#', ) end |
#direction_indicator ⇒ String
Returns an indicator about the sorting direction for the current column. The direction is either ‘ASC’ or ‘DESC’.
28 29 30 |
# File 'lib/acts_as_data_table/sortable_columns/renderers/default.rb', line 28 def direction_indicator @sortable.direction == 'ASC' ? 'Δ' : '∇' end |
#direction_link ⇒ String
Returns a link to change the sorting direction for an already active column.
42 43 44 45 46 47 48 |
# File 'lib/acts_as_data_table/sortable_columns/renderers/default.rb', line 42 def direction_link = @sortable..clone ['data-init'] = 'sortable-column-direction' ['data-remote'] = @sortable.remote ['data-url-change-direction'] = @sortable.urls.change_direction @action_view.link_to(direction_indicator, '#', ) end |
#to_html ⇒ String
Generates the actual HTML (= caption and direction links) to be embedded into the view
71 72 73 74 75 76 77 |
# File 'lib/acts_as_data_table/sortable_columns/renderers/default.rb', line 71 def to_html if @sortable.active + ' ' + direction_link else end end |