Skip to content

Commit f4e9206

Browse files
committed
Add notification counters to dashboard
1 parent ebcf6aa commit f4e9206

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

app/controllers/users_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,24 @@ def update
4343

4444
def dashboard
4545
redirect_to(root_url) unless user_signed_in?
46+
@pending = { main: current_user.unseen_notifications.count }
4647

4748
if current_user.admin?
4849
@contributor_applications = User.contributor_applications
4950
@curator_applications = User.curator_applications
51+
@pending[:admin] =
52+
@contributor_applications.count + @curator_applications.count
5053
end
5154

5255
if current_user.curator?
5356
@pending_registers = Register.pending_for_curation
57+
@pending[:curator] = @pending_registers.count
5458
end
5559

5660
if current_user.editor?
5761
@unpublished_registers =
5862
Register.where(validated: true, published: [false, nil])
63+
@pending[:curator] = @unpublished_registers.count
5964
end
6065
end
6166

app/views/users/_actions.html.erb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<h2>Actions</h2>
22
<ul class="nav flex-column">
3+
<li class="nav-item">
4+
<%= link_to(notifications_path, class: 'nav-link') do %>
5+
<%= fa_icon('bell') %>
6+
See all user notifications
7+
<% end %>
8+
</li>
39
<li class="nav-item">
410
<%= link_to(edit_user_registration_path, class: 'nav-link') do %>
511
<%= fa_icon('user-cog') %>

app/views/users/_dashboard_links.html.erb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010
<div class="btn-group-vertical w-100 pb-4">
1111
<% links.each do |role, icon| %>
1212
<% k = which == role.to_s ? 'btn-light' : 'btn-primary' %>
13-
<%= link_to(dashboard_url(tab: role), class: "btn text-left border border-primary #{k}") do %>
14-
<%= fa_icon(icon[0]) %> <%= icon[1] %>
13+
<%= link_to(dashboard_url(tab: role),
14+
class: "btn d-flex border border-primary #{k}") do %>
15+
<div class="flex-grow-1 text-left pl-1">
16+
<%= fa_icon(icon[0]) %>
17+
<%= icon[1] %>
18+
</div>
19+
<div class="badge badge-light badge-pill py-1 px-2"><%= @pending[role] || '' %></div>
1520
<% end %>
1621
<% end %>
1722
</div>

0 commit comments

Comments
 (0)