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