]> source.dussan.org Git - redmine.git/commitdiff
Add issue tracking table on the user profile page (#30421).
authorGo MAEDA <maeda@farend.jp>
Fri, 1 Feb 2019 23:46:05 +0000 (23:46 +0000)
committerGo MAEDA <maeda@farend.jp>
Fri, 1 Feb 2019 23:46:05 +0000 (23:46 +0000)
Patch by Go MAEDA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17844 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/users_controller.rb
app/views/users/show.html.erb
test/functional/users_controller_test.rb

index 65dd9a47016496a37589d84233b452ad16a5bb08..efc9dce4dff92374d3d519041d7a9cdf46aa6658 100644 (file)
@@ -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)
index b7ceba01ac065a57a15f08841f635fbf6e1ab174..488e4b93a0ec3c962bf1881fc19876ddf0993598 100644 (file)
 </ul>
 
 <h3><%=l(:label_issue_plural)%></h3>
-<ul>
-  <li><%= link_to l(:label_assigned_issues),
-        issues_path(:set_filter => 1, :assigned_to_id => ([@user.id] + @user.group_ids).join("|"), :sort => 'priority:desc,updated_on:desc') %>:
-      <%= Issue.visible.open.assigned_to(@user).count %>
-  <li><%= link_to l(:label_reported_issues),
-        issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id) %>:
-      <%= Issue.visible.where(:author_id => @user.id).count %>
-</ul>
+
+<table class="list issue-report">
+<thead>
+  <tr>
+    <th></th>
+    <th><%=l(:label_open_issues_plural)%></th>
+    <th><%=l(:label_closed_issues_plural)%></th>
+    <th><%=l(:label_total)%></th>
+  </tr>
+</thead>
+<tbody>
+  <% assigned_to_ids = ([@user.id] + @user.group_ids).join("|") %>
+  <% sort_cond = 'priority:desc,updated_on:desc' %>
+  <tr>
+    <td class="name">
+      <%= link_to l(:label_assigned_issues),
+        issues_path(:set_filter => 1, :assigned_to_id => assigned_to_ids, :sort => sort_cond) %>
+    </td>
+    <td>
+      <%= link_to @issue_counts[:assigned][:open],
+        issues_path(:set_filter => 1, :assigned_to_id => assigned_to_ids, :sort => sort_cond) %>
+    </td>
+    <td>
+      <%= 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) %>
+    </td>
+    <td class="total">
+      <%= link_to @issue_counts[:assigned][:total],
+        issues_path(:set_filter => 1, :status_id => '*', :assigned_to_id => assigned_to_ids, :sort => sort_cond) %>
+    </td>
+  </tr>
+  <tr>
+    <td class="name">
+      <%= link_to l(:label_reported_issues),
+        issues_path(:set_filter => 1, :author_id => @user.id, :sort => sort_cond) %>
+    </td>
+    <td>
+      <%= link_to @issue_counts[:reported][:open],
+        issues_path(:set_filter => 1, :author_id => @user.id, :sort => sort_cond) %>
+    </td>
+    <td>
+      <%= 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) %>
+    </td>
+    <td class="total">
+      <%= link_to @issue_counts[:reported][:total],
+        issues_path(:set_filter => 1, :status_id => '*', :author_id => @user.id, :sort => sort_cond) %>
+    </td>
+  </tr>
+</tbody>
+</table>
 
 <% unless @memberships.empty? %>
 <h3><%=l(:label_project_plural)%></h3>
index 1f2dd4f32674201ef76ba5d9373a21ab0fff0578..1160ec764ec1534bd15f6c6d51a85c4991cc239a 100644 (file)
@@ -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