mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-04 06:36:27 +08:00
Merge pull request #610 from okriuchykhin/ok_SCI_1253
Add notifications counter badge to project card [SCI-1253]
This commit is contained in:
commit
15f19b73fb
2 changed files with 11 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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 %>
|
||||
|
|
Loading…
Reference in a new issue