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 | |
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>
-rw-r--r-- | app/helpers/dashboard_helper.rb | 38 | ||||
-rw-r--r-- | app/views/dashboard/issues.html.haml | 1 | ||||
-rw-r--r-- | app/views/dashboard/merge_requests.html.haml | 1 | ||||
-rw-r--r-- | app/views/groups/issues.html.haml | 1 | ||||
-rw-r--r-- | app/views/groups/merge_requests.html.haml | 1 | ||||
-rw-r--r-- | app/views/projects/issues/_head.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/issues/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/merge_requests/index.html.haml | 3 | ||||
-rw-r--r-- | app/views/shared/_filter.html.haml | 6 | ||||
-rw-r--r-- | app/views/shared/_project_filter.html.haml | 6 |
10 files changed, 52 insertions, 9 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 diff --git a/app/views/dashboard/issues.html.haml b/app/views/dashboard/issues.html.haml index 9888da2f7f2..d3ff291eaa8 100644 --- a/app/views/dashboard/issues.html.haml +++ b/app/views/dashboard/issues.html.haml @@ -1,6 +1,5 @@ %h3.page-title Issues - %span.pull-right #{@issues.total_count} issues %p.light List all issues from all projects you have access to. diff --git a/app/views/dashboard/merge_requests.html.haml b/app/views/dashboard/merge_requests.html.haml index ee3bec2849d..7a9ea9f6f90 100644 --- a/app/views/dashboard/merge_requests.html.haml +++ b/app/views/dashboard/merge_requests.html.haml @@ -1,6 +1,5 @@ %h3.page-title Merge Requests - %span.pull-right #{@merge_requests.total_count} merge requests %p.light diff --git a/app/views/groups/issues.html.haml b/app/views/groups/issues.html.haml index 0eec2d6be0b..0152ae86833 100644 --- a/app/views/groups/issues.html.haml +++ b/app/views/groups/issues.html.haml @@ -1,6 +1,5 @@ %h3.page-title Issues - %span.pull-right #{@issues.total_count} issues %p.light Only issues from diff --git a/app/views/groups/merge_requests.html.haml b/app/views/groups/merge_requests.html.haml index 71adb2c5516..71d346d0469 100644 --- a/app/views/groups/merge_requests.html.haml +++ b/app/views/groups/merge_requests.html.haml @@ -1,6 +1,5 @@ %h3.page-title Merge Requests - %span.pull-right #{@merge_requests.total_count} merge requests %p.light Only merge requests from diff --git a/app/views/projects/issues/_head.html.haml b/app/views/projects/issues/_head.html.haml index 716ea7cefed..dad547d4ebc 100644 --- a/app/views/projects/issues/_head.html.haml +++ b/app/views/projects/issues/_head.html.haml @@ -2,8 +2,6 @@ = nav_link(controller: :issues) do = link_to project_issues_path(@project), class: "tab" do Browse Issues - - if current_controller?(:issues) - %span.badge.issue_counter #{@issues.total_count} = nav_link(controller: :milestones) do = link_to 'Milestones', project_milestones_path(@project), class: "tab" = nav_link(controller: :labels) do diff --git a/app/views/projects/issues/index.html.haml b/app/views/projects/issues/index.html.haml index 2e66d059565..5de77b8bf32 100644 --- a/app/views/projects/issues/index.html.haml +++ b/app/views/projects/issues/index.html.haml @@ -4,6 +4,6 @@ %i.icon-list.icon-2x .col-md-3.responsive-side = render 'shared/project_filter', project_entities_path: project_issues_path(@project), - labels: true, redirect: 'issues' + labels: true, redirect: 'issues', entity: 'issue' .col-md-9.issues-holder = render "issues" diff --git a/app/views/projects/merge_requests/index.html.haml b/app/views/projects/merge_requests/index.html.haml index 4bb803eb6df..0954fa8fcea 100644 --- a/app/views/projects/merge_requests/index.html.haml +++ b/app/views/projects/merge_requests/index.html.haml @@ -4,14 +4,13 @@ New Merge Request %h3.page-title Merge Requests - %span (#{@merge_requests.total_count}) %hr .row .fixed.sidebar-expand-button.hidden-lg.hidden-md %i.icon-list.icon-2x .col-md-3.responsive-side = render 'shared/project_filter', project_entities_path: project_merge_requests_path(@project), - labels: true, redirect: 'merge_requests' + labels: true, redirect: 'merge_requests', entity: 'merge_request' .col-md-9 .mr-filters.append-bottom-10 .dropdown.inline diff --git a/app/views/shared/_filter.html.haml b/app/views/shared/_filter.html.haml index 19ecc458e29..9e65ce11ade 100644 --- a/app/views/shared/_filter.html.haml +++ b/app/views/shared/_filter.html.haml @@ -6,12 +6,18 @@ %li{class: ("active" if params[:scope] == 'assigned-to-me')} = link_to filter_path(entity, scope: 'assigned-to-me') do Assigned to me + %span.pull-right + = assigned_entities_count(current_user, entity, @group) %li{class: ("active" if params[:scope] == 'authored')} = link_to filter_path(entity, scope: 'authored') do Created by me + %span.pull-right + = authored_entities_count(current_user, entity, @group) %li{class: ("active" if params[:scope] == 'all')} = link_to filter_path(entity, scope: 'all') do Everyone's + %span.pull-right + = authorized_entities_count(current_user, entity, @group) %fieldset.status-filter %legend State diff --git a/app/views/shared/_project_filter.html.haml b/app/views/shared/_project_filter.html.haml index 743b4fba542..38cb1208cdc 100644 --- a/app/views/shared/_project_filter.html.haml +++ b/app/views/shared/_project_filter.html.haml @@ -6,12 +6,18 @@ %li{class: ("active" if params[:scope] == 'all')} = link_to project_filter_path(scope: 'all') do Everyone's + %span.pull-right + = authorized_entities_count(current_user, entity, @project) %li{class: ("active" if params[:scope] == 'assigned-to-me')} = link_to project_filter_path(scope: 'assigned-to-me') do Assigned to me + %span.pull-right + = assigned_entities_count(current_user, entity, @project) %li{class: ("active" if params[:scope] == 'created-by-me')} = link_to project_filter_path(scope: 'created-by-me') do Created by me + %span.pull-right + = authored_entities_count(current_user, entity, @project) %fieldset %legend State |