Skip to content

Commit

Permalink
Check order with direction
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed Nov 9, 2024
1 parent 1a0fcbd commit c441425
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/datagrid/ordering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ def order_column
end

# @param column [String, Datagrid::Columns::Column]
# @param desc [nil, Boolean] confirm order direction as well if specified
# @return [Boolean] true if given grid is ordered by given column.
def ordered_by?(column)
order_column == column_by_name(column)
def ordered_by?(column, desc = nil)
order_column == column_by_name(column) &&
(desc.nil? || (desc ? descending? : !descending?))
end

private
Expand Down

0 comments on commit c441425

Please sign in to comment.