2013-03-27 13:04:29 -04:00
|
|
|
module NotificationsHelper
|
2015-05-21 17:49:06 -04:00
|
|
|
include IconsHelper
|
|
|
|
|
2016-03-28 12:17:42 -04:00
|
|
|
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'
|
2013-07-31 10:05:22 -04:00
|
|
|
end
|
|
|
|
end
|
2015-09-14 19:37:11 -04:00
|
|
|
|
2016-03-29 07:08:30 -04:00
|
|
|
def notification_icon(level, text = nil)
|
|
|
|
icon("#{notification_icon_class(level)} fw", text: text)
|
2016-03-28 12:17:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def notification_title(level)
|
|
|
|
case level.to_sym
|
|
|
|
when :participating
|
|
|
|
'Participate'
|
|
|
|
when :mention
|
|
|
|
'On mention'
|
2016-03-28 17:22:28 -04:00
|
|
|
else
|
|
|
|
level.to_s.titlecase
|
2015-09-14 19:37:11 -04:00
|
|
|
end
|
|
|
|
end
|
2015-09-14 21:33:24 -04:00
|
|
|
|
2016-05-27 10:56:43 -04:00
|
|
|
def notification_description(level)
|
|
|
|
case level.to_sym
|
|
|
|
when :participating
|
|
|
|
'You will only receive notifications from related resources'
|
|
|
|
when :mention
|
|
|
|
'You will receive notifications only for comments in which you were @mentioned'
|
|
|
|
when :watch
|
|
|
|
'You will receive notifications for any activity'
|
|
|
|
when :disabled
|
|
|
|
'You will not get any notifications via email'
|
|
|
|
when :global
|
|
|
|
'Use your global notification setting'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-28 12:17:42 -04:00
|
|
|
def notification_list_item(level, setting)
|
|
|
|
title = notification_title(level)
|
|
|
|
|
|
|
|
data = {
|
|
|
|
notification_level: level,
|
|
|
|
notification_title: title
|
|
|
|
}
|
|
|
|
|
2016-05-27 10:56:43 -04:00
|
|
|
content_tag(:li, role: "menuitem") do
|
|
|
|
link_to '#', class: "update-notification #{('is-active' if setting.level == level)}", data: data do
|
|
|
|
link_output = content_tag(:strong, title, class: 'dropdown-menu-inner-title')
|
|
|
|
link_output << content_tag(:span, notification_description(level), class: 'dropdown-menu-inner-content')
|
2015-11-14 13:38:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-06-06 11:50:54 -04:00
|
|
|
|
|
|
|
def notification_level_radio_buttons
|
|
|
|
html = ""
|
|
|
|
|
|
|
|
NotificationSetting.levels.each_key do |level|
|
|
|
|
level = level.to_sym
|
|
|
|
next if level == :global
|
|
|
|
|
|
|
|
html << content_tag(:div, class: "radio") do
|
|
|
|
content_tag(:label, { value: level }) do
|
2016-06-09 15:33:31 -04:00
|
|
|
radio_button_tag(:"global_notification_setting[level]", level, @global_notification_setting.level.to_sym == level) +
|
2016-06-06 11:50:54 -04:00
|
|
|
content_tag(:div, level.to_s.capitalize, class: "level-title") +
|
2016-06-09 15:33:31 -04:00
|
|
|
content_tag(:p, notification_description(level))
|
2016-06-06 11:50:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
html.html_safe
|
|
|
|
end
|
2013-03-27 13:04:29 -04:00
|
|
|
end
|