Show counters in sidebar filter in same way like we did for projects page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
a338954c33
commit
cff1758486
10 changed files with 52 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
%h3.page-title
|
||||
Merge Requests
|
||||
%span.pull-right #{@merge_requests.total_count} merge requests
|
||||
|
||||
|
||||
%p.light
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
%h3.page-title
|
||||
Issues
|
||||
%span.pull-right #{@issues.total_count} issues
|
||||
|
||||
%p.light
|
||||
Only issues from
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
%h3.page-title
|
||||
Merge Requests
|
||||
%span.pull-right #{@merge_requests.total_count} merge requests
|
||||
|
||||
%p.light
|
||||
Only merge requests from
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue