class Acts::DataTable::SortableColumns::Renderers::Default
Public Class Methods
new(sortable, action_view)
click to toggle source
# 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
Public Instance Methods
caption()
click to toggle source
@return [String] The column header’s caption
# File lib/acts_as_data_table/sortable_columns/renderers/default.rb, line 35 def caption @sortable.caption end
caption_link()
click to toggle source
@return [String] a link to toggle a column
# File lib/acts_as_data_table/sortable_columns/renderers/default.rb, line 53 def caption_link link_options = @sortable.html_options.clone link_options['data-init'] = 'sortable-column' link_options['data-remote'] = @sortable.remote link_options['data-url-toggle'] = @sortable.urls.toggle link_options['data-url-set-base'] = @sortable.urls.set_base link_options['data-url-change-direction'] = @sortable.urls.change_direction link_options['data-active'] = 'true' if @sortable.active @action_view.link_to(@sortable.caption, '#', link_options) end
direction_indicator()
click to toggle source
@return [String] an indicator about the sorting direction for the current column.
The direction is either 'ASC' or 'DESC'
# File lib/acts_as_data_table/sortable_columns/renderers/default.rb, line 28 def direction_indicator @sortable.direction == 'ASC' ? 'Δ' : '∇' end
direction_link()
click to toggle source
@return [String] a link to change the sorting direction for an already active column
# File lib/acts_as_data_table/sortable_columns/renderers/default.rb, line 42 def direction_link link_options = @sortable.html_options.clone link_options['data-init'] = 'sortable-column-direction' link_options['data-remote'] = @sortable.remote link_options['data-url-change-direction'] = @sortable.urls.change_direction @action_view.link_to(direction_indicator, '#', link_options) end
to_html()
click to toggle source
Generates the actual HTML (= caption and direction links) to be embedded into the view
@return [String] the generated HTML code
# File lib/acts_as_data_table/sortable_columns/renderers/default.rb, line 71 def to_html if @sortable.active caption_link + ' ' + direction_link else caption_link end end