debian-mirror-gitlab/app/helpers/notifications_helper.rb

49 lines
964 B
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
module NotificationsHelper
2015-09-11 14:41:01 +05:30
include IconsHelper
2016-06-02 11:05:42 +05:30
def notification_icon_class(level)
case level.to_sym
when :disabled
'microphone-slash'
when :participating
'volume-up'
when :watch
'eye'
when :mention
'at'
when :global
'globe'
2014-09-02 18:07:02 +05:30
end
end
2015-09-25 12:07:36 +05:30
2016-06-02 11:05:42 +05:30
def notification_icon(level, text = nil)
icon("#{notification_icon_class(level)} fw", text: text)
2015-09-25 12:07:36 +05:30
end
2016-06-02 11:05:42 +05:30
def notification_title(level)
case level.to_sym
when :participating
'Participate'
when :mention
'On mention'
else
level.to_s.titlecase
2015-11-26 14:37:03 +05:30
end
end
2016-06-02 11:05:42 +05:30
def notification_list_item(level, setting)
title = notification_title(level)
data = {
notification_level: level,
notification_title: title
}
2015-09-25 12:07:36 +05:30
2016-06-02 11:05:42 +05:30
content_tag(:li, class: ('active' if setting.level == level)) do
link_to '#', class: 'update-notification', data: data do
notification_icon(level, title)
end
end
2015-09-25 12:07:36 +05:30
end
2014-09-02 18:07:02 +05:30
end