BigW Consortium Gitlab

notifications_helper.rb 964 Bytes
Newer Older
1
module NotificationsHelper
2 3
  include IconsHelper

4 5 6 7 8 9 10 11 12 13 14 15
  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'
16 17
    end
  end
18

19 20
  def notification_icon(level, text = nil)
    icon("#{notification_icon_class(level)} fw", text: text)
21 22 23 24 25 26 27 28
  end

  def notification_title(level)
    case level.to_sym
    when :participating
      'Participate'
    when :mention
      'On mention'
29 30
    else
      level.to_s.titlecase
31 32
    end
  end
33

34 35 36 37 38 39 40 41
  def notification_list_item(level, setting)
    title = notification_title(level)

    data = {
      notification_level: level,
      notification_title: title
    }

42
    content_tag(:li, class: ('active' if setting.level == level)) do
43
      link_to '#', class: 'update-notification', data: data do
44
        notification_icon(level, title)
45 46 47
      end
    end
  end
48
end