2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-08-16 16:30:55 +02:00
|
|
|
module TabsHelper
|
2023-09-20 14:00:18 +02:00
|
|
|
def tab_i18n_key_from_status(status)
|
|
|
|
case status
|
|
|
|
when 'a-suivre'
|
|
|
|
'views.instructeurs.dossiers.tab_steps.to_follow' # i18n-tasks-use t('views.instructeurs.dossiers.tab_steps.to_follow')
|
|
|
|
when 'suivis'
|
|
|
|
'pluralize.followed'
|
|
|
|
when 'traites'
|
|
|
|
'pluralize.processed'
|
|
|
|
when 'tous'
|
|
|
|
'views.instructeurs.dossiers.tab_steps.total' # i18n-tasks-use t('views.instructeurs.dossiers.tab_steps.total')
|
2024-07-18 14:15:29 +02:00
|
|
|
when 'supprimes'
|
|
|
|
'pluralize.dossiers_supprimes'
|
2023-09-20 14:00:18 +02:00
|
|
|
when 'expirant'
|
|
|
|
'pluralize.dossiers_close_to_expiration'
|
|
|
|
when 'archives'
|
|
|
|
'pluralize.archived'
|
|
|
|
else
|
|
|
|
fail ArgumentError, "Unknown tab status: #{status}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-16 16:30:55 +02:00
|
|
|
def tab_item(label, url, active: false, badge: nil, notification: false)
|
|
|
|
render partial: 'shared/tab_item', locals: {
|
|
|
|
label: label,
|
|
|
|
url: url,
|
|
|
|
active: active,
|
|
|
|
badge: badge,
|
|
|
|
notification: notification
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-09-07 11:28:32 +02:00
|
|
|
def dynamic_tab_item(label, url_or_urls, badge: nil, notification: false)
|
|
|
|
urls = [url_or_urls].flatten
|
|
|
|
url = urls.first
|
|
|
|
active = urls.any? { |u| current_page?(u) }
|
|
|
|
|
|
|
|
tab_item(label, url, active: active, badge: badge, notification: notification)
|
2018-08-16 16:30:55 +02:00
|
|
|
end
|
|
|
|
end
|