diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-10 18:54:31 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-10 18:54:31 +0400 |
commit | cff1758486675cb41ad959c8eefde11b016c0571 (patch) | |
tree | c5c2cd6539e9babc4bb8ed8ab98bedba88b94128 /app/helpers | |
parent | a338954c331ed451c7b7dd39b28b9649dfca26ba (diff) |
Show counters in sidebar filter in same way like we did for projects page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/dashboard_helper.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index d5712ab3374..c4e33e3308f 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -35,4 +35,42 @@ module DashboardHelper path << "?#{options.to_param}" path end + + def assigned_entities_count(current_user, entity, scope = nil) + items = current_user.send("assigned_" + entity.pluralize).opened + + if scope.kind_of?(Group) + items = items.of_group(scope) + elsif scope.kind_of?(Project) + items = items.of_projects(scope) + end + + items.count + end + + def authored_entities_count(current_user, entity, scope = nil) + items = current_user.send(entity.pluralize).opened + + if scope.kind_of?(Group) + items = items.of_group(scope) + elsif scope.kind_of?(Project) + items = items.of_projects(scope) + end + + items.count + end + + def authorized_entities_count(current_user, entity, scope = nil) + items = entity.classify.constantize.opened + + if scope.kind_of?(Group) + items = items.of_group(scope) + elsif scope.kind_of?(Project) + items = items.of_projects(scope) + else + items = items.of_projects(current_user.authorized_projects) + end + + items.count + end end |