2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-09-26 17:14:20 +02:00
|
|
|
class Dossiers::NotifiedToggleComponent < ApplicationComponent
|
|
|
|
def initialize(procedure:, procedure_presentation:)
|
|
|
|
@procedure = procedure
|
|
|
|
@procedure_presentation = procedure_presentation
|
|
|
|
@current_sort = procedure_presentation.sort
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def opposite_order
|
|
|
|
@procedure_presentation.opposite_order_for(current_table, current_column)
|
|
|
|
end
|
|
|
|
|
|
|
|
def active?
|
2022-12-20 11:46:17 +01:00
|
|
|
sorted_by_notifications? && order_desc?
|
2022-09-26 17:14:20 +02:00
|
|
|
end
|
|
|
|
|
2022-12-20 11:46:17 +01:00
|
|
|
def order_desc?
|
|
|
|
current_order == 'desc'
|
2022-09-26 17:14:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def current_order
|
|
|
|
@current_sort['order']
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_table
|
|
|
|
@current_sort['table']
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_column
|
|
|
|
@current_sort['column']
|
|
|
|
end
|
|
|
|
|
|
|
|
def sorted_by_notifications?
|
|
|
|
current_table == 'notifications' && current_column == 'notifications'
|
|
|
|
end
|
|
|
|
end
|