mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-01 03:57:15 +00:00
Fixed that watchers list is not updated when changing project on the new issue form (#17762).
git-svn-id: http://svn.redmine.org/redmine/trunk@16511 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1cd985dd6b
commit
9506ff1f40
@ -375,6 +375,9 @@ class Issue < ActiveRecord::Base
|
||||
def project=(project, keep_tracker=false)
|
||||
project_was = self.project
|
||||
association(:project).writer(project)
|
||||
if project != project_was
|
||||
@safe_attribute_names = nil
|
||||
end
|
||||
if project_was && project && project_was != project
|
||||
@assignable_versions = nil
|
||||
|
||||
|
||||
14
app/views/issues/_watchers_form.html.erb
Normal file
14
app/views/issues/_watchers_form.html.erb
Normal file
@ -0,0 +1,14 @@
|
||||
<% if @issue.safe_attribute? 'watcher_user_ids' -%>
|
||||
<p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
|
||||
<span id="watchers_inputs">
|
||||
<%= watchers_checkboxes(@issue, users_for_new_issue_watchers(@issue)) %>
|
||||
</span>
|
||||
<span class="search_for_watchers">
|
||||
<%= link_to l(:label_search_for_watchers),
|
||||
{:controller => 'watchers', :action => 'new', :project_id => @issue.project},
|
||||
:class => 'icon icon-add-bullet',
|
||||
:remote => true,
|
||||
:method => 'get' %>
|
||||
</span>
|
||||
</p>
|
||||
<% end %>
|
||||
@ -32,20 +32,9 @@
|
||||
|
||||
<p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @issue} %></p>
|
||||
|
||||
<% if @issue.safe_attribute? 'watcher_user_ids' -%>
|
||||
<p id="watchers_form"><label><%= l(:label_issue_watchers) %></label>
|
||||
<span id="watchers_inputs">
|
||||
<%= watchers_checkboxes(@issue, users_for_new_issue_watchers(@issue)) %>
|
||||
</span>
|
||||
<span class="search_for_watchers">
|
||||
<%= link_to l(:label_search_for_watchers),
|
||||
{:controller => 'watchers', :action => 'new', :project_id => @issue.project},
|
||||
:class => 'icon icon-add-bullet',
|
||||
:remote => true,
|
||||
:method => 'get' %>
|
||||
</span>
|
||||
</p>
|
||||
<% end %>
|
||||
<div id="watchers_form_container">
|
||||
<%= render :partial => 'issues/watchers_form' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= submit_tag l(:button_create) %>
|
||||
|
||||
@ -1 +1,4 @@
|
||||
replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
|
||||
<% if params[:form_update_triggered_by] == "issue_project_id" %>
|
||||
$("#watchers_form_container").html('<%= escape_javascript(render :partial => 'issues/watchers_form') %>');
|
||||
<% end %>
|
||||
|
||||
@ -803,6 +803,16 @@ class IssueTest < ActiveSupport::TestCase
|
||||
assert_equal 1, issue.status_id
|
||||
end
|
||||
|
||||
def test_safe_attributes_names_should_be_updated_when_changing_project
|
||||
issue = Issue.new
|
||||
with_current_user(User.find(2)) do
|
||||
assert_not_include 'watcher_user_ids', issue.safe_attribute_names
|
||||
|
||||
issue.project_id = 1
|
||||
assert_include 'watcher_user_ids', issue.safe_attribute_names
|
||||
end
|
||||
end
|
||||
|
||||
def test_safe_attributes_names_should_not_include_disabled_field
|
||||
tracker = Tracker.new(:core_fields => %w(assigned_to_id fixed_version_id))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user