Commit b592907d48f90dbae43fcfb1a96a30cebd14e243
1 parent
2b0420fa
Exists in
tasks_keep_filter_params
Added @params_tags property to create input hidden tags with filter params
Showing
3 changed files
with
25 additions
and
2 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
... | ... | @@ -18,6 +18,14 @@ class TasksController < MyProfileController |
18 | 18 | @responsible_candidates = profile.members.by_role(profile.roles.reject {|r| !r.has_permission?('perform_task')}) if profile.organization? |
19 | 19 | |
20 | 20 | @view_only = !current_person.has_permission?(:perform_task, profile) |
21 | + | |
22 | + @params_tags = [] | |
23 | + params.each do |key,value| | |
24 | + if key =~ /filter_/ && value | |
25 | + @params_tags << view_context.hidden_field_tag(key, value) | |
26 | + end | |
27 | + end | |
28 | + | |
21 | 29 | end |
22 | 30 | |
23 | 31 | def processed | ... | ... |
app/views/tasks/index.html.erb
... | ... | @@ -46,6 +46,16 @@ |
46 | 46 | </p> |
47 | 47 | <% else %> |
48 | 48 | <%= form_tag :action => 'close' do%> |
49 | + | |
50 | + <% if !@params_tags.empty? %> | |
51 | + <p> | |
52 | + <% @params_tags.each do |hidden_tag| %> | |
53 | + | |
54 | + <%= hidden_tag %> | |
55 | + <% end %> | |
56 | + </p> | |
57 | + <% end %> | |
58 | + | |
49 | 59 | <% button_bar(:class => 'task-actions') do %> |
50 | 60 | <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> |
51 | 61 | <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> | ... | ... |
test/functional/tasks_controller_test.rb
... | ... | @@ -12,7 +12,7 @@ class TasksControllerTest < ActionController::TestCase |
12 | 12 | @request = ActionController::TestRequest.new |
13 | 13 | @response = ActionController::TestResponse.new |
14 | 14 | |
15 | - self.profile = create_user('testuser').person | |
15 | + self.profile = create_user('testuser', :email => 'testuser@email.com').person | |
16 | 16 | @controller.stubs(:profile).returns(profile) |
17 | 17 | login_as 'testuser' |
18 | 18 | end |
... | ... | @@ -77,7 +77,12 @@ class TasksControllerTest < ActionController::TestCase |
77 | 77 | end |
78 | 78 | |
79 | 79 | should 'keep filters after close a task' do |
80 | - t = profile.tasks.build; t.save! | |
80 | + requestor = User.create!(:login => 'john', :email => 'john@example.com', :password => 'test', :password_confirmation => 'test') | |
81 | + c = Community.create!(:name => 'test comm', :identifier => 'test_comm', :moderated_articles => false) | |
82 | + t = InviteMember.create!(:requestor => requestor.person, :target => profile, :spam => false, :community_id => c.id) | |
83 | + | |
84 | + get :index, :filter_type => t.type | |
85 | + assert_tag_in_string(assigns(:params_tags).join(' '), :tag => 'input', :attributes => { :value => 'InviteMember' }) | |
81 | 86 | |
82 | 87 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}}, :filter_type => t.type |
83 | 88 | assert_redirected_to :action => 'index', :filter_type => t.type | ... | ... |