Skip to content

Commit

Permalink
Support tag_options in deprecated datagrid_column_classes
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 18, 2024
1 parent af0985f commit f5fb22d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 8 additions & 7 deletions lib/datagrid/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,7 @@ def datagrid_order_path(grid, column, descending)
datagrid_renderer.order_path(grid, column, descending, request)
end

protected

def datagrid_renderer
Renderer.for(self)
end

# @!visibility private
def datagrid_column_classes(grid, column)
Datagrid::Utils.warn_once(<<~MSG)
datagrid_column_classes is deprecated. Assign necessary classes manually.
Expand All @@ -182,7 +177,13 @@ def datagrid_column_classes(grid, column)
order_class = if grid.ordered_by?(column)
["ordered", grid.descending ? "desc" : "asc"]
end
[column.name, order_class, column.options[:class]].compact.join(" ")
class_names(column.name, order_class, column.options[:class], column.tag_options[:class])
end

protected

def datagrid_renderer
Renderer.for(self)
end
end
end
8 changes: 6 additions & 2 deletions spec/datagrid/helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -731,13 +731,17 @@ def param_name
grid = test_grid(order: :name, descending: true) do
scope { Entry }
column(:name)
column(:category, tag_options: { class: "long-column" })
column(:group_id, class: "short-column")
end
silence_deprecator do
expect(subject.send(:datagrid_column_classes, grid, :name)).to eq(
expect(subject.datagrid_column_classes(grid, :name)).to eq(
"name ordered desc",
)
expect(subject.send(:datagrid_column_classes, grid, :group_id)).to eq(
expect(subject.datagrid_column_classes(grid, :category)).to eq(
"category long-column",
)
expect(subject.datagrid_column_classes(grid, :group_id)).to eq(
"group_id short-column",
)
end
Expand Down

0 comments on commit f5fb22d

Please sign in to comment.