From fe7e3e7df502d7873b7df8cd196e4b61049238ec Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Fri, 1 Feb 2019 23:46:05 +0000 Subject: [PATCH] Add issue tracking table on the user profile page (#30421). Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@17844 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/users_controller.rb | 10 ++++ app/views/users/show.html.erb | 59 ++++++++++++++++++++---- test/functional/users_controller_test.rb | 19 ++++++++ 3 files changed, 80 insertions(+), 8 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 65dd9a470..efc9dce4d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -78,6 +78,16 @@ class UsersController < ApplicationController # show projects based on current user visibility @memberships = @user.memberships.preload(:roles, :project).where(Project.visible_condition(User.current)).to_a + @issue_counts = {} + @issue_counts[:assigned] = { + :total => Issue.visible.assigned_to(@user).count, + :open => Issue.visible.open.assigned_to(@user).count + } + @issue_counts[:reported] = { + :total => Issue.visible.where(:author_id => @user.id).count, + :open => Issue.visible.open.where(:author_id => @user.id).count + } + respond_to do |format| format.html { events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index b7ceba01a..488e4b93a 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -23,14 +23,57 @@

<%=l(:label_issue_plural)%>

- + + + + + + + + + + + + <% assigned_to_ids = ([@user.id] + @user.group_ids).join("|") %> + <% sort_cond = 'priority:desc,updated_on:desc' %> + + + + + + + + + + + + + +
<%=l(:label_open_issues_plural)%><%=l(:label_closed_issues_plural)%><%=l(:label_total)%>
+ <%= link_to l(:label_assigned_issues), + issues_path(:set_filter => 1, :assigned_to_id => assigned_to_ids, :sort => sort_cond) %> + + <%= link_to @issue_counts[:assigned][:open], + issues_path(:set_filter => 1, :assigned_to_id => assigned_to_ids, :sort => sort_cond) %> + + <%= link_to @issue_counts[:assigned][:total] - @issue_counts[:assigned][:open], + issues_path(:set_filter => 1, :status_id => 'c', :assigned_to_id => assigned_to_ids, :sort => sort_cond) %> + + <%= link_to @issue_counts[:assigned][:total], + issues_path(:set_filter => 1, :status_id => '*', :assigned_to_id => assigned_to_ids, :sort => sort_cond) %> +
+ <%= link_to l(:label_reported_issues), + issues_path(:set_filter => 1, :author_id => @user.id, :sort => sort_cond) %> + + <%= link_to @issue_counts[:reported][:open], + issues_path(:set_filter => 1, :author_id => @user.id, :sort => sort_cond) %> + + <%= link_to @issue_counts[:reported][:total] - @issue_counts[:reported][:open], + issues_path(:set_filter => 1, :status_id => 'c', :author_id => @user.id, :sort => sort_cond) %> + + <%= link_to @issue_counts[:reported][:total], + issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id, :sort => sort_cond) %> +
<% unless @memberships.empty? %>

<%=l(:label_project_plural)%>

diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 1f2dd4f32..1160ec764 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -185,6 +185,25 @@ class UsersControllerTest < Redmine::ControllerTest assert_select 'h2', :text => /John Smith/ end + def test_show_issues_counts + @request.session[:user_id] = 2 + get :show, :params => {:id => 2} + assert_select 'table.list.issue-report>tbody' do + assert_select 'tr:nth-of-type(1)' do + assert_select 'td:nth-of-type(1)>a', :text => 'Assigned issues' + assert_select 'td:nth-of-type(2)>a', :text => '1' # open + assert_select 'td:nth-of-type(3)>a', :text => '0' # closed + assert_select 'td:nth-of-type(4)>a', :text => '1' # total + end + assert_select 'tr:nth-of-type(2)' do + assert_select 'td:nth-of-type(1)>a', :text => 'Reported issues' + assert_select 'td:nth-of-type(2)>a', :text => '11' # open + assert_select 'td:nth-of-type(3)>a', :text => '2' # closed + assert_select 'td:nth-of-type(4)>a', :text => '13' # total + end + end + end + def test_new get :new assert_response :success