start integrating notifications into account menu

This commit is contained in:
Devin Howard 2016-11-24 11:07:57 -05:00
parent dcb70e86e2
commit 46c563afb2
4 changed files with 27 additions and 6 deletions

View file

@ -56,8 +56,7 @@ class NotificationsController < ApplicationController
private
def set_receipts
@receipts = current_user.mailbox.receipts
.includes(:notification).where(mailbox_type: nil)
@receipts = current_user.mailboxer_notification_receipts
end
def set_notification

View file

@ -37,4 +37,12 @@ module ApplicationHelper
def invite_link
"#{request.base_url}/join" + (current_user ? "?code=#{current_user.code}" : '')
end
def user_has_unread_notifications?
return false if current_user.nil?
current_user.mailboxer_notification_receipts.each do |receipt|
return true if receipt.is_read == false
end
false
end
end

View file

@ -114,4 +114,12 @@ class User < ApplicationRecord
def mailboxer_email(object)
nil # email
end
def mailboxer_notifications
mailbox.notifications
end
def mailboxer_notification_receipts
mailbox.receipts.includes(:notification).where(mailbox_type: nil)
end
end

View file

@ -18,14 +18,20 @@
<%= link_to "Admin", metacodes_path %>
</li>
<% end %>
<li class="accountListItem accountInvite openLightbox" data-open="invite">
<div class="accountIcon"></div>
<span>Share Invite</span>
</li>
<li class="accountListItem accountApps">
<div class="accountIcon"></div>
<%= link_to "Apps", oauth_authorized_applications_path %>
</li>
<% if current_user.present? %>
<li class="accountListItem accountNotifications <%= user_has_unread_notifications? ? 'unread' : 'read' %>">
<div class="accountIcon"></div>
<%= link_to "Notifications", notifications_path %>
</li>
<% end %>
<li class="accountListItem accountInvite openLightbox" data-open="invite">
<div class="accountIcon"></div>
<span>Share Invite</span>
</li>
<li class="accountListItem accountLogout">
<div class="accountIcon"></div>
<%= link_to "Sign Out", "/logout", id: "Logout" %>