Merge pull request #610 from okriuchykhin/ok_SCI_1253

Add notifications counter badge to project card [SCI-1253]
This commit is contained in:
okriuchykhin 2017-05-11 11:11:09 +02:00 committed by GitHub
commit 15f19b73fb
2 changed files with 11 additions and 0 deletions

View file

@ -189,4 +189,12 @@ class Project < ActiveRecord::Base
.distinct
end
end
def notifications_count(user)
res = 0
assigned_modules(user).find_each do |t|
res += 1 if t.is_overdue? || t.is_one_day_prior?
end
res
end
end

View file

@ -75,6 +75,9 @@ data-project-users-tab-url="<%= url_for project_user_projects_path(project_id: p
<li role="presentation">
<a class="btn btn-link" href="<%= url_for notifications_project_path(id: project.id, format: :json) %>" aria-controls="notifications-<%= project.id %>" role="tab" data-remote="true">
<span class="glyphicon glyphicon-bell"></span>
<% if project.notifications_count(current_user).positive? %>
<span class="badge badge-indicator"><%= project.notifications_count(current_user) %></span>
<% end %>
</a>
</li>
<% end %>