diff --git a/app/logical/table_builder.rb b/app/logical/table_builder.rb index e89faca2d..fac059117 100644 --- a/app/logical/table_builder.rb +++ b/app/logical/table_builder.rb @@ -10,6 +10,12 @@ class TableBuilder @name = name || attribute @name = @name.to_s.titleize unless @name.kind_of?(String) + + if @name.present? + column_class = "#{@name.parameterize.dasherize}-column" + @header_attributes[:class] = "#{column_class} #{@header_attributes[:class]}".strip + @body_attributes[:class] = "#{column_class} #{@body_attributes[:class]}".strip + end end def value(item, i, j) @@ -30,6 +36,11 @@ class TableBuilder @items = items @columns = [] @table_attributes = { class: "striped", **table_attributes } + + if items.respond_to?(:model_name) + @table_attributes[:id] ||= "#{items.model_name.plural.dasherize}-table" + end + yield self if block_given? end