diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb
index 7746ec2f6..cf70bdfd7 100644
--- a/app/controllers/activities_controller.rb
+++ b/app/controllers/activities_controller.rb
@@ -32,13 +32,15 @@ class ActivitiesController < ApplicationController
@date_to ||= User.current.today + 1
@date_from = @date_to - @days
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
- if params[:user_id].present?
- @author = User.visible.active.find(params[:user_id])
+ @authors = []
+ if params[:user_ids].present?
+ @authors = User.visible.active.where(:id => params[:user_ids])
+ raise ActiveRecord::RecordNotFound if @authors.empty?
end
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
:with_subprojects => @with_subprojects,
- :author => @author)
+ :authors => @authors)
pref = User.current.pref
@activity.scope_select {|t| !params["show_#{t}"].nil?}
if @activity.scope.present?
@@ -47,7 +49,7 @@ class ActivitiesController < ApplicationController
pref.save
end
else
- if @author.nil?
+ if @authors.empty?
scope = pref.activity_scope & @activity.event_types
@activity.scope = scope.present? ? scope : :default
else
@@ -62,7 +64,7 @@ class ActivitiesController < ApplicationController
@activity.events(@date_from, @date_to)
end
- if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, events.size, User.current, current_language])
+ if events.empty? || stale?(:etag => [@activity.scope, @date_to, @date_from, @with_subprojects, @authors.first, @authors.size, events.first, events.size, User.current, current_language])
respond_to do |format|
format.html do
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
@@ -70,8 +72,8 @@ class ActivitiesController < ApplicationController
end
format.atom do
title = l(:label_activity)
- if @author
- title = @author.name
+ if @authors.any?
+ title = @authors.map(&:name).join(", ")
elsif @activity.scope.size == 1
title = l("label_#{@activity.scope.first.singularize}_plural")
end
diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb
index 83f67b1b8..1aa5edf5d 100644
--- a/app/views/activities/index.html.erb
+++ b/app/views/activities/index.html.erb
@@ -1,4 +1,4 @@
-
<%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %>
+<%= @authors.empty? ? l(:label_activity) : l(:label_user_activity, @authors.map{|a| link_to_user(a)}.join(',')).html_safe %>
<%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %>
@@ -38,7 +38,8 @@
<%= l(:label_user) %>
- <%= select_tag('user_id', activity_authors_options_for_select(@project, params[:user_id]), include_blank: true) %>
+ <%= select_tag('user_ids[]', activity_authors_options_for_select(@project, params[:user_ids]), include_blank: true, multiple: (params[:user_ids]&.count.to_i > 1)) %>
+
<% @activity.event_types.each do |t| %>
@@ -46,7 +47,7 @@
<%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
<% end %>
@@ -59,4 +60,4 @@
<% end %>
<% end %>
-<% html_title(l(:label_activity), @author) -%>
+<% html_title(l(:label_activity), @authors) -%>
diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb
index 224e16492..1c52fe5ac 100644
--- a/lib/redmine/activity/fetcher.rb
+++ b/lib/redmine/activity/fetcher.rb
@@ -24,7 +24,7 @@ module Redmine
attr_reader :user, :project, :scope
def initialize(user, options={})
- options.assert_valid_keys(:project, :with_subprojects, :author)
+ options.assert_valid_keys(:project, :with_subprojects, :author, :authors)
@user = user
@project = options[:project]
@options = options
@@ -87,10 +87,15 @@ module Redmine
def events(from = nil, to = nil, options={})
e = []
@options[:limit] = options[:limit]
+ authors = [[@options[:author]], @options[:authors]].flatten.compact
@scope.each do |event_type|
constantized_providers(event_type).each do |provider|
- e += provider.find_events(event_type, @user, from, to, @options)
+ if authors.any?
+ e += authors.map { |author| provider.find_events(event_type, @user, from, to, @options.merge(:author => author)) }.flatten
+ else
+ e += provider.find_events(event_type, @user, from, to, @options)
+ end
end
end
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 91da19229..836c56016 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1025,7 +1025,7 @@ $(document).ready(function(){
$('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
toggleDisabledInit();
- $('#content').on('click', '.toggle-multiselect', function() {
+ $('#content, #sidebar').on('click', '.toggle-multiselect', function() {
toggleMultiSelect($(this).siblings('select'));
$(this).toggleClass('icon-toggle-plus icon-toggle-minus');
});
diff --git a/test/functional/activities_controller_test.rb b/test/functional/activities_controller_test.rb
index fe112da48..224e9a203 100644
--- a/test/functional/activities_controller_test.rb
+++ b/test/functional/activities_controller_test.rb
@@ -82,13 +82,15 @@ class ActivitiesControllerTest < Redmine::ControllerTest
get(
:index,
:params => {
- :user_id => 2
+ :user_ids => [2, 3]
}
)
assert_response :success
- assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
- assert_select '#sidebar select#user_id option[value="2"][selected=selected]'
+ { 2 => 'John Smith', 3 => 'Dave Lopper' }.each do |user_id, user_name|
+ assert_select "h2 a[href='/users/#{user_id}']", :text => user_name
+ assert_select "#sidebar select#user_ids_ option[value='#{user_id}'][selected=selected]"
+ end
i1 = Issue.find(1)
d1 = User.find(1).time_to_date(i1.created_on)
@@ -101,7 +103,7 @@ class ActivitiesControllerTest < Redmine::ControllerTest
get(
:index,
:params => {
- :user_id => 299
+ :user_ids => [299]
}
)
assert_response 404
@@ -113,7 +115,7 @@ class ActivitiesControllerTest < Redmine::ControllerTest
@request.session[:user_id] = nil
get :index, :params => {
- :user_id => user.id
+ :user_ids => [user.id]
}
assert_response 404
@@ -199,12 +201,12 @@ class ActivitiesControllerTest < Redmine::ControllerTest
get(
:index,
:params => {
- :user_id => 2,
+ :user_ids => [2, 3],
:format => 'atom'
}
)
assert_response :success
- assert_select 'title', :text => "Redmine: #{User.find(2).name}"
+ assert_select 'title', :text => "Redmine: #{User.find(2).name}, #{User.find(3).name}"
end
def test_index_atom_feed_with_subprojects