1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/helpers/application_helper.rb

104 lines
2 KiB
Ruby
Raw Normal View History

2018-11-22 14:58:12 -05:00
# frozen_string_literal: true
2019-09-15 09:26:15 -04: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
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-10-21 04:12:49 -04:00
def there_is
tag.i class: 'text-muted' do
translate :there_is
end
end
2019-08-28 14:21:35 -04:00
def none
tag.i class: 'text-muted' do
translate :none
end
end
def bool_badge(value)
if value
tag.span class: 'badge badge-pill badge-success' do
translate :yes
end
else
tag.span class: 'badge badge-pill badge-secondary' do
translate :no
end
end
end
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