Feature #20458 » 20458.patch
| app/controllers/activities_controller.rb | ||
|---|---|---|
|
@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?
|
||
| ... | ... | |
|
pref.save
|
||
|
end
|
||
|
else
|
||
|
if @author.nil?
|
||
|
if @authors.empty?
|
||
|
scope = pref.activity_scope & @activity.event_types
|
||
|
@activity.scope = scope.present? ? scope : :default
|
||
|
else
|
||
| ... | ... | |
|
@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)}
|
||
| ... | ... | |
|
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
|
||
| app/views/activities/index.html.erb | ||
|---|---|---|
|
<h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h2>
|
||
|
<h2><%= @authors.empty? ? l(:label_activity) : l(:label_user_activity, @authors.map{|a| link_to_user(a)}.join(',')).html_safe %></h2>
|
||
|
<p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p>
|
||
| ... | ... | |
|
</p>
|
||
|
<p>
|
||
|
<%= 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)) %>
|
||
|
<span class="toggle-multiselect icon-only"></span>
|
||
|
</p>
|
||
|
<ul>
|
||
|
<% @activity.event_types.each do |t| %>
|
||
| ... | ... | |
|
<%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
|
||
|
<label for="show_<%=t%>">
|
||
|
<%= link_to(l("label_#{t.singularize}_plural"),
|
||
|
{"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from]})%>
|
||
|
{"show_#{t}" => 1, :user_ids => params[:user_ids], :from => params[:from]})%>
|
||
|
</label>
|
||
|
</li>
|
||
|
<% end %>
|
||
| ... | ... | |
|
<% end %>
|
||
|
<% end %>
|
||
|
<% html_title(l(:label_activity), @author) -%>
|
||
|
<% html_title(l(:label_activity), @authors) -%>
|
||
| lib/redmine/activity/fetcher.rb | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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
|
||
| public/javascripts/application.js | ||
|---|---|---|
|
$('#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');
|
||
|
});
|
||
| test/functional/activities_controller_test.rb | ||
|---|---|---|
|
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)
|
||
| ... | ... | |
|
get(
|
||
|
:index,
|
||
|
:params => {
|
||
|
:user_id => 299
|
||
|
:user_ids => [299]
|
||
|
}
|
||
|
)
|
||
|
assert_response 404
|
||
| ... | ... | |
|
@request.session[:user_id] = nil
|
||
|
get :index, :params => {
|
||
|
:user_id => user.id
|
||
|
:user_ids => [user.id]
|
||
|
}
|
||
|
assert_response 404
|
||
| ... | ... | |
|
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
|
||
- « Previous
- 1
- 2
- 3
- Next »