65 lines
4.8 KiB
Plaintext
65 lines
4.8 KiB
Plaintext
= nav_entry t('views.navigation.notifications'), notifications_path, badge: notification_count, class: 'visible-xs'
|
|
- notifications = Notification.for(current_user).limit(4)
|
|
%li.dropdown.hidden-xs
|
|
%a.dropdown-toggle{href: "#", "data-toggle" => "dropdown"}
|
|
- if notification_count.nil?
|
|
%i.fa.fa-bell-o
|
|
- else
|
|
%i.fa.fa-bell
|
|
%span.sr-only Notifications
|
|
%span.badge= notification_count
|
|
%ul.dropdown-menu.notification--dropdown
|
|
- if notifications.count == 0
|
|
%li.centre.text-muted New notifications will appear here.
|
|
- else
|
|
- notifications.each do |notification|
|
|
%li{class: (notification.new? ? 'list-group-item-warning' : '')}
|
|
.media.notification--dropdown-media
|
|
- case notification.target_type
|
|
- when "Answer"
|
|
.pull-left
|
|
%img.img-rounded.notification--dropdown-img{src: gravatar_url(notification.target.user)}
|
|
.media-body
|
|
%h6.media-heading.notification--dropdown-user
|
|
= user_screen_name notification.target.user
|
|
.notification--dropdown-text
|
|
= raw t('views.notifications.answer.body', question: link_to(t('views.notifications.answer.question'), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.id)), time: time_ago_in_words(notification.target.created_at))
|
|
- when "Relationship"
|
|
.pull-left
|
|
%img.img-rounded.notification--dropdown-img{src: gravatar_url(notification.target.source)}
|
|
.media-body
|
|
%h6.media-heading.notification--dropdown-user
|
|
= user_screen_name notification.target.source
|
|
.notification--dropdown-text
|
|
= raw t('views.notifications.relationship.body', time: time_ago_in_words(notification.target.created_at))
|
|
- when "Smile"
|
|
.pull-left
|
|
%img.img-rounded.notification--dropdown-img{src: gravatar_url(notification.target.user)}
|
|
.media-body
|
|
%h6.media-heading.notification--dropdown-user
|
|
= user_screen_name notification.target.user
|
|
.notification--dropdown-text
|
|
= raw t('views.notifications.smile.body', content: link_to(t('views.notifications.smile.answer'), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), time: time_ago_in_words(notification.target.created_at))
|
|
- when "CommentSmile"
|
|
.pull-left
|
|
%img.img-rounded.notification--dropdown-img{src: gravatar_url(notification.target.user)}
|
|
.media-body
|
|
%h6.media-heading.notification--dropdown-user
|
|
= user_screen_name notification.target.user
|
|
.notification--dropdown-text
|
|
= raw t('views.notifications.smile.body', content: link_to(t('views.notifications.smile.comment'), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.comment.answer.id)), time: time_ago_in_words(notification.target.created_at))
|
|
- when "Comment"
|
|
.pull-left
|
|
%img.img-rounded.notification--dropdown-img{src: gravatar_url(notification.target.user)}
|
|
.media-body
|
|
%h6.media-heading.notification--dropdown-user
|
|
= user_screen_name notification.target.user
|
|
.notification--dropdown-text
|
|
- if notification.target.answer.user == current_user
|
|
= raw t('views.notifications.comment.body', content: link_to(t('views.notifications.comment.your', user: user_screen_name(current_user, false, false)), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), time: time_tooltip(notification.target))
|
|
- elsif notification.target.user == notification.target.answer.user
|
|
= raw t('views.notifications.comment.body', content: link_to(t('views.notifications.comment.their', user: user_screen_name(notification.target.answer.user, false, false)), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), time: time_tooltip(notification.target))
|
|
- else
|
|
= raw t('views.notifications.comment.body', content: link_to(t('views.notifications.comment.user', user: user_screen_name(notification.target.answer.user, false, false)), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), time: time_tooltip(notification.target))
|
|
%li= link_to "#{t('views.notifications.show')}#{t('views.notifications.mark') if notifications.pluck(:new).any?}", notifications_path
|