demarches-normaliennes/app/helpers/tabs_helper.rb
2023-09-28 12:35:20 +02:00

40 lines
1.2 KiB
Ruby

module TabsHelper
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')
when 'supprimes_recemment'
'pluralize.dossiers_supprimes_recemment'
when 'expirant'
'pluralize.dossiers_close_to_expiration'
when 'archives'
'pluralize.archived'
else
fail ArgumentError, "Unknown tab status: #{status}"
end
end
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
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)
end
end