Module: NotificationsHelper

Includes:
IconsHelper
Defined in:
app/helpers/notifications_helper.rb

Instance Method Summary collapse

Methods included from IconsHelper

#audit_icon, #boolean_to_icon, #file_type_icon_class, #icon, #spinner, #visibility_level_icon

Instance Method Details

#notification_icon(level, text = nil) ⇒ Object


19
20
21
# File 'app/helpers/notifications_helper.rb', line 19

def notification_icon(level, text = nil)
  icon("#{notification_icon_class(level)} fw", text: text)
end

#notification_icon_class(level) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/notifications_helper.rb', line 4

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'
  end
end

#notification_list_item(level, setting) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/notifications_helper.rb', line 34

def notification_list_item(level, setting)
  title = notification_title(level)

  data = {
    notification_level: level,
    notification_title: title
  }

  (:li, class: ('active' if setting.level == level)) do
    link_to '#', class: 'update-notification', data: data do
      notification_icon(level, title)
    end
  end
end

#notification_title(level) ⇒ Object


23
24
25
26
27
28
29
30
31
32
# File 'app/helpers/notifications_helper.rb', line 23

def notification_title(level)
  case level.to_sym
  when :participating
    'Participate'
  when :mention
    'On mention'
  else
    level.to_s.titlecase
  end
end