mirror of
https://github.com/redmine/redmine.git
synced 2025-11-12 16:26:03 +01:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -23,14 +23,57 @@
|
||||
</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>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user