2024-09-23 10:35:00 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class SortedColumn
|
2024-09-26 17:18:43 +02:00
|
|
|
attr_reader :column, :order
|
2024-09-23 10:35:00 +02:00
|
|
|
|
|
|
|
def initialize(column:, order:)
|
|
|
|
@column = column
|
|
|
|
@order = order
|
|
|
|
end
|
|
|
|
|
|
|
|
def ascending? = @order == 'asc'
|
|
|
|
|
2024-09-24 15:06:12 +02:00
|
|
|
def opposite_order = ascending? ? 'desc' : 'asc'
|
|
|
|
|
2024-09-23 10:35:00 +02:00
|
|
|
def ==(other)
|
|
|
|
other&.column == column && other.order == order
|
|
|
|
end
|
2024-10-08 19:40:19 +02:00
|
|
|
|
|
|
|
def sort_by_notifications?
|
|
|
|
@column.notifications? && @order == 'desc'
|
|
|
|
end
|
2024-09-23 10:35:00 +02:00
|
|
|
end
|