actually add some code here
This commit is contained in:
parent
45e08651af
commit
c8b02bbf50
|
@ -1,43 +1,61 @@
|
||||||
= nav_entry "Notifications", notifications_path, badge: notification_count
|
.visible-xs= nav_entry "Notifications", notifications_path, badge: notification_count
|
||||||
|
- notifications = Notification.for(current_user).limit(4)
|
||||||
%li.dropdown.hidden-xs
|
%li.dropdown.hidden-xs
|
||||||
%a.dropdown-toggle{href: "#", "data-toggle" => "dropdown"}
|
%a.dropdown-toggle{href: "#", "data-toggle" => "dropdown"}
|
||||||
Notifications
|
Notifications
|
||||||
%span.badge= notification_count
|
%span.badge= notification_count
|
||||||
%ul.dropdown-menu.notification--dropdown
|
%ul.dropdown-menu.notification--dropdown
|
||||||
%li
|
- if notifications.count == 0
|
||||||
|
%p New notifications will appear here.
|
||||||
|
- else
|
||||||
|
- notifications.each do |notification|
|
||||||
|
%li{class: (notification.new? ? 'list-group-item-warning' : '')}
|
||||||
.media.notification--dropdown-media
|
.media.notification--dropdown-media
|
||||||
|
- case notification.target_type
|
||||||
|
- when "Answer"
|
||||||
.pull-left
|
.pull-left
|
||||||
%img.img-rounded.notification--dropdown-img
|
%img.img-rounded.notification--dropdown-img{src: gravatar_url(notification.target.user)}
|
||||||
.media-body
|
.media-body
|
||||||
%h6.media-heading.notification--dropdown-user
|
%h6.media-heading.notification--dropdown-user
|
||||||
username
|
= user_screen_name notification.target.user
|
||||||
.notification--dropdown-text
|
.notification--dropdown-text
|
||||||
followed you 33 minutes ago
|
answered
|
||||||
%li
|
%a{href: show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.id), title: "#{notification.target.content[0..40]}...", data: { toggle: :tooltip, placement: :top }}
|
||||||
.media.notification--dropdown-media
|
your question
|
||||||
|
= time_ago_in_words notification.target.created_at
|
||||||
|
ago
|
||||||
|
- when "Relationship"
|
||||||
.pull-left
|
.pull-left
|
||||||
%img.img-rounded.notification--dropdown-img
|
%img.img-rounded.notification--dropdown-img{src: gravatar_url(notification.target.source)}
|
||||||
.media-body
|
.media-body
|
||||||
%h6.media-heading.notification--dropdown-user
|
%h6.media-heading.notification--dropdown-user
|
||||||
username
|
= user_screen_name notification.target.source
|
||||||
.notification--dropdown-text
|
.notification--dropdown-text
|
||||||
smiled at your answer about 1 hour ago
|
followed you
|
||||||
%li
|
= time_ago_in_words notification.target.created_at
|
||||||
.media.notification--dropdown-media
|
ago
|
||||||
|
- when "Smile"
|
||||||
.pull-left
|
.pull-left
|
||||||
%img.img-rounded.notification--dropdown-img
|
%img.img-rounded.notification--dropdown-img{src: gravatar_url(notification.target.user)}
|
||||||
.media-body
|
.media-body
|
||||||
%h6.media-heading.notification--dropdown-user
|
%h6.media-heading.notification--dropdown-user
|
||||||
username
|
= user_screen_name notification.target.user
|
||||||
.notification--dropdown-text
|
.notification--dropdown-text
|
||||||
answered your question about 4 hours ago
|
smiled at
|
||||||
%li
|
%a{href: show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id), title: "#{notification.target.answer.content[0..40]}...", data: { toggle: :tooltip, placement: :top }}
|
||||||
.media.notification--dropdown-media
|
your answer
|
||||||
|
= time_ago_in_words notification.target.created_at
|
||||||
|
ago
|
||||||
|
- when "Comment"
|
||||||
.pull-left
|
.pull-left
|
||||||
%img.img-rounded.notification--dropdown-img
|
%img.img-rounded.notification--dropdown-img{src: gravatar_url(notification.target.user)}
|
||||||
.media-body
|
.media-body
|
||||||
%h6.media-heading.notification--dropdown-user
|
%h6.media-heading.notification--dropdown-user
|
||||||
username
|
= user_screen_name notification.target.user
|
||||||
.notification--dropdown-text
|
.notification--dropdown-text
|
||||||
commented on your answer about 5 hours ago
|
commented on
|
||||||
%li= link_to "Show all Notifications", notifications_path
|
%a{href: show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id), title: "#{notification.target.answer.content[0..40]}...", data: { toggle: :tooltip, placement: :top }}
|
||||||
|
your answer
|
||||||
|
= time_ago_in_words notification.target.created_at
|
||||||
|
ago
|
||||||
|
%li= link_to "Show all notifications#{" and mark them as read" if notifications.pluck(:new).any?}", notifications_path
|
Loading…
Reference in New Issue