2018-11-22 14:58:12 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-22 14:33:08 -05:00
|
|
|
module ApplicationHelper
|
2019-03-26 20:32:35 -04:00
|
|
|
NAV_TABS_LIST_HTML_CLASS = {
|
2019-04-28 09:34:46 -04:00
|
|
|
tabs: 'nav nav-tabs d-none d-sm-flex',
|
2019-03-26 20:32:35 -04:00
|
|
|
pills: 'nav nav-pills d-flex d-sm-none flex-column',
|
|
|
|
}.freeze
|
|
|
|
|
2019-06-23 11:59:44 -04:00
|
|
|
def federal_subjects_controller?
|
|
|
|
controller_path == 'federal_subjects'
|
2019-03-27 01:47:21 -04:00
|
|
|
end
|
|
|
|
|
2019-03-26 23:23:23 -04:00
|
|
|
def staff_controller?
|
|
|
|
controller_path.start_with?('staff')
|
|
|
|
end
|
|
|
|
|
2018-12-03 12:58:39 -05:00
|
|
|
def bootstrap_class_for_flash(flash_type)
|
|
|
|
case flash_type
|
|
|
|
when 'success'
|
|
|
|
'alert-success'
|
2018-12-13 21:13:49 -05:00
|
|
|
when 'error', 'recaptcha_error'
|
2018-12-03 12:58:39 -05:00
|
|
|
'alert-danger'
|
|
|
|
when 'alert'
|
|
|
|
'alert-warning'
|
|
|
|
else
|
|
|
|
'alert-info'
|
|
|
|
end
|
|
|
|
end
|
2019-03-26 20:32:35 -04:00
|
|
|
|
|
|
|
def nav_tabs(scope_name, current_tab_name, options)
|
|
|
|
capture do
|
|
|
|
concat nav_tabs_list scope_name, current_tab_name, :tabs, options
|
|
|
|
concat nav_tabs_list scope_name, current_tab_name, :pills, options
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def nav_tabs_list(scope_name, current_tab_name, format, options)
|
|
|
|
tag.ul class: NAV_TABS_LIST_HTML_CLASS[format] do
|
|
|
|
options.each do |(k, v)|
|
|
|
|
concat nav_tabs_item scope_name, current_tab_name, k, v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def nav_tabs_item(scope_name, current_tab_name, tab_name, url)
|
|
|
|
tag.li class: 'nav-item' do
|
|
|
|
link_to translate(tab_name, scope: [:nav_tabs, scope_name]),
|
|
|
|
url,
|
|
|
|
class: "nav-link #{:active if current_tab_name == tab_name}"
|
|
|
|
end
|
|
|
|
end
|
2018-11-22 14:33:08 -05:00
|
|
|
end
|