Skip to content

Commit a99205b

Browse files
author
Nikolay Moskvin
committed
Added count to each model as badge
1 parent 03653ce commit a99205b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

app/helpers/rails_admin/application_helper.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ def navigation(nodes_stack, nodes, level = 0)
9696
url = url_for(action: :index, controller: 'rails_admin/main', model_name: model_param)
9797
level_class = " nav-level-#{level}" if level > 0
9898
nav_icon = node.navigation_icon ? %(<i class="#{node.navigation_icon}"></i>).html_safe : ''
99+
count = node.abstract_model.count
100+
badge = %( <span class='badge'>#{count}</span>).html_safe
99101
li = content_tag :li, 'data-model' => model_param do
100-
link_to nav_icon + capitalize_first_letter(node.label_plural), url, class: "pjax#{level_class}"
102+
link_to badge + nav_icon + capitalize_first_letter(node.label_plural), url, class: "pjax#{level_class}"
101103
end
102104
li + navigation(nodes_stack, nodes_stack.select { |n| n.parent.to_s == node.abstract_model.model_name }, level + 1)
103105
end.join.html_safe

app/views/layouts/rails_admin/application.html.haml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
.col-sm-3.col-md-2.reset-left
1919
.sidebar-nav
2020
%ul.nav.nav-pills.nav-stacked= main_navigation
21-
-# %ul.nav.nav-list= static_navigation
21+
%ul.nav.nav-pills.nav-stacked= static_navigation
2222
.col-sm-9.col-sm-offset-3.col-md-10.col-md-offset-2
2323
.row
2424
.content{:'data-pjax-container' => true}= render template: 'layouts/rails_admin/pjax'

0 commit comments

Comments
 (0)