1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-03-03 07:51:54 +00:00

Activity page to remember user's selection of activities (#1605).

git-svn-id: http://svn.redmine.org/redmine/trunk@14678 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2015-10-15 19:06:22 +00:00
parent 486a4dfbc8
commit 589bde0899
4 changed files with 37 additions and 2 deletions

View File

@ -37,8 +37,21 @@ class ActivitiesController < ApplicationController
@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
:with_subprojects => @with_subprojects,
:author => @author)
pref = User.current.pref
@activity.scope_select {|t| !params["show_#{t}"].nil?}
@activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
if @activity.scope.present?
if params[:submit].present?
pref.activity_scope = @activity.scope
pref.save
end
else
if @author.nil?
scope = pref.activity_scope & @activity.event_types
@activity.scope = scope.present? ? scope : :default
else
@activity.scope = :all
end
end
events = @activity.events(@date_from, @date_to)

View File

@ -59,4 +59,7 @@ class UserPreference < ActiveRecord::Base
def no_self_notified; (self[:no_self_notified] == true || self[:no_self_notified] == '1'); end
def no_self_notified=(value); self[:no_self_notified]=value; end
def activity_scope; Array(self[:activity_scope]) ; end
def activity_scope=(value); self[:activity_scope]=value ; end
end

View File

@ -61,7 +61,7 @@
<p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
<% end %>
<%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => 'submit' %></p>
<% end %>
<% end %>

View File

@ -157,4 +157,23 @@ class ActivitiesControllerTest < ActionController::TestCase
assert_response :success
assert_not_include journal, assigns(:events_by_day).values.flatten
end
def test_index_with_submitted_scope_should_save_as_preference
@request.session[:user_id] = 2
get :index, :show_issues => '1', :show_messages => '1', :submit => 'Apply'
assert_response :success
assert_equal %w(issues messages), User.find(2).pref.activity_scope.sort
end
def test_index_scope_should_default_to_user_preference
pref = User.find(2).pref
pref.activity_scope = %w(issues news)
pref.save!
@request.session[:user_id] = 2
get :index
assert_response :success
assert_equal %w(issues news), assigns(:activity).scope
end
end