Module: NotificationsHelper

Defined in:
app/helpers/notifications_helper.rb

Instance Method Summary collapse

Instance Method Details

Create link to destroy notification


38
39
40
# File 'app/helpers/notifications_helper.rb', line 38

def link_to_destroy_notification(note)
  link_to 'delete', user_notification_path(note, user_id: @user.to_param), method: :delete
end

Create link to mark all as read


27
28
29
30
31
32
33
# File 'app/helpers/notifications_helper.rb', line 27

def link_to_mark_all_as_read(user, opts = {})
  opts.merge!({
    method: :patch,
    class: 'button'
  })
  link_to "Mark all as read", user_notifications_path(user_id: user.to_param), opts
end

Create link to inbox with number of notifications


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

def link_to_notifications(user, count=nil, opts = {})
  txt = "Inbox"
  txt += "(#{count})" unless count.to_i.zero?
  link_to txt, user_notifications_path(user_id: user), opts
end

#notification_classes(note) ⇒ Object

Get a array of html classes from Notification attributes


6
7
8
9
10
11
# File 'app/helpers/notifications_helper.rb', line 6

def notification_classes(note)
  classes = ["notification"]
  classes.push(note.event) if note.event?
  classes.push(note.level_to_s) if note.level?
  note.read ? classes.push("read") : classes.push("unread")
end

#notification_timestamp(note) ⇒ Object

Create timestamp for html5


45
46
47
# File 'app/helpers/notifications_helper.rb', line 45

def notification_timestamp(note)
  time_date_hours_seconds( @user.to_local_time( note.created_at ) )
end