Class: IndexFor::WiceHeadColumnBuilder
- Inherits:
-
HeadColumnBuilder
- Object
- Builder
- HeadColumnBuilder
- IndexFor::WiceHeadColumnBuilder
- Defined in:
- lib/index_for/builders/wice_head_column_builder.rb
Instance Attribute Summary
Attributes inherited from Builder
#html_options, #object, #template
Instance Method Summary collapse
Methods inherited from HeadColumnBuilder
Methods inherited from Builder
#actions, #association, #attributes, #fields_for, #initialize
Constructor Details
This class inherits a constructor from IndexFor::Builder
Instance Method Details
#attribute(attribute_name, options = {}) ⇒ Object
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 |
# File 'lib/index_for/builders/wice_head_column_builder.rb', line 7 def attribute attribute_name, = {} model_class = [:model] || [:model] || @object.class order = "#{model_class.table_name}.#{attribute_name}" params = @template.params direction = params[:direction] || "asc" reverse_direction = if order != params[:order] || params[:direction] && params[:direction] == "desc" "asc" else "desc" end sorting_class = if order == params[:order] "sorting #{direction}" else "sorting" if params[:sortable] != false end append_html_class , attribute_class_name(attribute_name), sorting_class params = template.params.permit! [:html] ||= {} [:html][:data] ||= {} [:html][:data][:href] = @template.url_for(params.merge(order: order, direction: reverse_direction)) wrap_with :table_head_cell, attribute_label(attribute_name, ), end |