Class: Admino::Table::HeadRow
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#resource_klass ⇒ Object
readonly
Returns the value of attribute resource_klass.
Attributes inherited from Row
Instance Method Summary collapse
- #actions(*args, &block) ⇒ Object
- #column(*args, &block) ⇒ Object
-
#initialize(resource_klass, query, view_context) ⇒ HeadRow
constructor
A new instance of HeadRow.
- #to_html ⇒ Object
Methods inherited from Row
#parse_action_args, #parse_column_args
Constructor Details
#initialize(resource_klass, query, view_context) ⇒ HeadRow
Returns a new instance of HeadRow.
10 11 12 13 14 15 16 |
# File 'lib/admino/table/head_row.rb', line 10 def initialize(resource_klass, query, view_context) @resource_klass = resource_klass @query = query @columns = "" super(view_context) end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
8 9 10 |
# File 'lib/admino/table/head_row.rb', line 8 def query @query end |
#resource_klass ⇒ Object (readonly)
Returns the value of attribute resource_klass.
7 8 9 |
# File 'lib/admino/table/head_row.rb', line 7 def resource_klass @resource_klass end |
Instance Method Details
#actions(*args, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/admino/table/head_row.rb', line 18 def actions(*args, &block) = (:actions) label = I18n.t( :"#{resource_klass.model_name.i18n_key}.title", scope: 'table.actions', default: [ :title, 'Actions' ] ) @columns << h.content_tag(:th, label.to_s, ) end |
#column(*args, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/admino/table/head_row.rb', line 29 def column(*args, &block) params = parse_column_args(args) attribute_name = params[:attribute_name] label = params[:label] = params[:html_options] if label.nil? && attribute_name label = resource_klass.human_attribute_name(attribute_name.to_s) end = (attribute_name) = Showcase::Helpers::HtmlOptions.new() .merge_attrs!() = .to_h sorting_scope = .delete(:sorting) if sorting_scope raise ArgumentError, 'query object is required' unless query = .delete(:sorting_html_options) { {} } label = query.sorting.scope_link(sorting_scope, label, ) end @columns << h.content_tag(:th, label.to_s, .to_h) end |
#to_html ⇒ Object
55 56 57 |
# File 'lib/admino/table/head_row.rb', line 55 def to_html @columns.html_safe end |