table builder: fix various incorrect css classes.

Change calling convention to explicitly indicate whether the attributes
are for the <th> element or the <td> element. Fixes various cases where
the two were mixed up.

* Fix .col-expand classes not being set correctly on the /post_versions,
  /pool_versions, and /notes pages.

* Fix .updater and .updated-at classes not being set correctly on the
  /forum_topics page.

* Fix the name param being ignored (noticeable in the post count field
  on the /tags page).

* Don't pass empty string when column has no name.
This commit is contained in:
evazion
2020-01-07 01:21:42 -06:00
parent cdb42aad66
commit 5c913d8ad1
36 changed files with 61 additions and 61 deletions

View File

@@ -2,12 +2,14 @@ class TableBuilder
class Column
attr_reader :attribute, :name, :block, :header_attributes, :body_attributes
def initialize(attribute = nil, header_attributes=nil, body_attributes=nil, &block)
def initialize(attribute = nil, th: {}, td: {}, width: nil, name: nil, &block)
@attribute = attribute
@header_attributes = header_attributes
@body_attributes = body_attributes
@name = attribute.kind_of?(String) ? attribute : attribute.to_s.titleize
@header_attributes = { width: width, **th }
@body_attributes = td
@block = block
@name = name || attribute
@name = @name.to_s.titleize unless @name.kind_of?(String)
end
def value(item, i, j)