2018-11-22 14:58:12 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-22 14:33:08 -05:00
|
|
|
module ApplicationHelper
|
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
|
|
|
|
|
2019-09-03 19:11:55 -04:00
|
|
|
def timezones_collection
|
|
|
|
[*negative_timezones_collection, *positive_timezones_collection].freeze
|
|
|
|
end
|
|
|
|
|
|
|
|
def positive_timezones_collection
|
|
|
|
0.upto(11).flat_map do |n|
|
|
|
|
s = n.to_s.rjust(2, '0')
|
|
|
|
|
|
|
|
[
|
|
|
|
"#{s}:00:00",
|
|
|
|
"#{s}:15:00",
|
|
|
|
"#{s}:30:00",
|
|
|
|
"#{s}:45:00",
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def negative_timezones_collection
|
|
|
|
12.downto(1).flat_map do |n|
|
|
|
|
s1 = n.to_s.rjust(2, '0')
|
|
|
|
s2 = (n - 1).to_s.rjust(2, '0')
|
|
|
|
|
|
|
|
[
|
|
|
|
"-#{s1}:00:00",
|
|
|
|
"-#{s2}:45:00",
|
|
|
|
"-#{s2}:30:00",
|
|
|
|
"-#{s2}:15:00",
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-28 14:21:35 -04:00
|
|
|
def none
|
|
|
|
tag.i class: 'text-muted' do
|
|
|
|
translate :none
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-22 14:46:57 -04:00
|
|
|
def translate_enum(type, value)
|
|
|
|
translate value, scope: [:enums, type]
|
|
|
|
end
|
|
|
|
|
2019-09-03 12:18:01 -04:00
|
|
|
def pagination(collection)
|
|
|
|
tag.div do
|
|
|
|
concat tag.div(class: 'd-flex justify-content-center') {
|
|
|
|
paginate collection
|
|
|
|
}
|
|
|
|
|
|
|
|
concat tag.div(class: 'd-flex justify-content-center') {
|
2019-09-03 12:54:06 -04:00
|
|
|
tag.span { page_entries_info collection }
|
2019-09-03 12:18:01 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-15 04:34:48 -04:00
|
|
|
def open_action(url)
|
|
|
|
link_to url, role: :button, class: 'btn btn-light btn-sm' do
|
|
|
|
concat tag.i class: 'far fa-eye'
|
|
|
|
concat ' '.html_safe
|
|
|
|
concat translate :open_action
|
|
|
|
end
|
|
|
|
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
|
2018-11-22 14:33:08 -05:00
|
|
|
end
|