mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-23 08:51:13 +00:00
Add an interface to filter activities by user (#33602).
Patch by Mizuki ISHIKAWA. git-svn-id: http://svn.redmine.org/redmine/trunk@20752 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f8d96bb359
commit
a8072b0d0f
@ -30,4 +30,11 @@ module ActivitiesHelper
|
|||||||
end
|
end
|
||||||
sorted_events
|
sorted_events
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def activity_authors_options_for_select(project, selected)
|
||||||
|
options = []
|
||||||
|
options += [["<< #{l(:label_me)} >>", User.current.id]] if User.current.logged?
|
||||||
|
options += Query.new(project: project).users.select{|user| user.active?}.map{|user| [user.name, user.id]}
|
||||||
|
options_for_select(options, selected)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -36,6 +36,10 @@
|
|||||||
<%= t(:label_days_to_html, :days => @days, :date => date_field_tag('from', '', :value => (@date_to - 1), :size => 10)) %>
|
<%= t(:label_days_to_html, :days => @days, :date => date_field_tag('from', '', :value => (@date_to - 1), :size => 10)) %>
|
||||||
<%= calendar_for('from') %>
|
<%= calendar_for('from') %>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<%= l(:label_user) %>
|
||||||
|
<%= select_tag('user_id', activity_authors_options_for_select(@project, params[:user_id]), include_blank: true) %>
|
||||||
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<% @activity.event_types.each do |t| %>
|
<% @activity.event_types.each do |t| %>
|
||||||
<li>
|
<li>
|
||||||
@ -51,7 +55,6 @@
|
|||||||
<%= hidden_field_tag 'with_subprojects', 0, :id => nil %>
|
<%= hidden_field_tag 'with_subprojects', 0, :id => nil %>
|
||||||
<p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
|
<p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
|
|
||||||
<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => 'submit' %></p>
|
<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => 'submit' %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@ -87,6 +87,7 @@ class ActivitiesControllerTest < Redmine::ControllerTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
|
assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
|
||||||
|
assert_select '#sidebar select#user_id option[value="2"][selected=selected]'
|
||||||
|
|
||||||
i1 = Issue.find(1)
|
i1 = Issue.find(1)
|
||||||
d1 = User.find(1).time_to_date(i1.created_on)
|
d1 = User.find(1).time_to_date(i1.created_on)
|
||||||
|
|||||||
@ -109,4 +109,24 @@ class ActivitiesHelperTest < Redmine::HelperTest
|
|||||||
sort_activity_events(events).map {|event, grouped| [event.name, grouped]}
|
sort_activity_events(events).map {|event, grouped| [event.name, grouped]}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_activity_authors_options_for_select_if_current_user_is_admin
|
||||||
|
User.current = User.find(1)
|
||||||
|
project = Project.find(1)
|
||||||
|
|
||||||
|
options = [["<< #{l(:label_me)} >>", 1], ['Dave Lopper', 3], ['John Smith', 2], ['Redmine Admin', 1], ['User Misc', 8]]
|
||||||
|
assert_equal(
|
||||||
|
options_for_select(options, nil),
|
||||||
|
activity_authors_options_for_select(project, nil))
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_activity_authors_options_for_select_if_current_user_is_anonymous
|
||||||
|
User.current = nil
|
||||||
|
project = Project.find(1)
|
||||||
|
|
||||||
|
options = [['Dave Lopper', 3], ['John Smith', 2]]
|
||||||
|
assert_equal(
|
||||||
|
options_for_select(options, nil),
|
||||||
|
activity_authors_options_for_select(project, nil))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user