2013-03-27 17:04:29 +00:00
|
|
|
module NotificationsHelper
|
2015-05-21 21:49:06 +00:00
|
|
|
include IconsHelper
|
|
|
|
|
2016-03-28 16:17:42 +00: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 14:05:22 +00:00
|
|
|
end
|
|
|
|
end
|
2015-09-14 23:37:11 +00:00
|
|
|
|
2016-03-28 16:17:42 +00:00
|
|
|
def notification_icon(level)
|
|
|
|
icon("#{notification_icon_class(level)} fw")
|
|
|
|
end
|
|
|
|
|
|
|
|
def notification_title(level)
|
|
|
|
case level.to_sym
|
|
|
|
when :participating
|
|
|
|
'Participate'
|
|
|
|
when :mention
|
|
|
|
'On mention'
|
2016-03-28 21:22:28 +00:00
|
|
|
else
|
|
|
|
level.to_s.titlecase
|
2015-09-14 23:37:11 +00:00
|
|
|
end
|
|
|
|
end
|
2015-09-15 01:33:24 +00:00
|
|
|
|
2016-03-28 16:17:42 +00:00
|
|
|
def notification_list_item(level, setting)
|
|
|
|
title = notification_title(level)
|
|
|
|
|
|
|
|
data = {
|
|
|
|
notification_level: level,
|
|
|
|
notification_title: title
|
|
|
|
}
|
|
|
|
|
|
|
|
content_tag(:li, class: active_level_for(setting, level)) do
|
|
|
|
link_to '#', class: 'update-notification', data: data do
|
|
|
|
icon("#{notification_icon_class(level)} fw", text: title)
|
2015-11-14 18:38:05 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-28 16:17:42 +00:00
|
|
|
def active_level_for(setting, level)
|
|
|
|
'active' if setting.level == level
|
2015-09-15 01:33:24 +00:00
|
|
|
end
|
2013-03-27 17:04:29 +00:00
|
|
|
end
|