Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Real support for cross-project issues relations

  • Loading branch information...
commit ccfcdb2bc6a2e469473bc3ec11b60e624af5eaf2 1 parent d809efa
@fprochazka authored
View
10 app/controllers/issues_controller.rb
@@ -130,7 +130,7 @@ def show
def new
respond_to do |format|
format.html { render :action => 'new', :layout => !request.xhr? }
- format.js { render :partial => 'attributes' }
+ format.js { render :template => 'issues/new.rhtml', :layout => FALSE }
end
end
@@ -299,10 +299,14 @@ def build_new_issue_from_params
else
@issue = @project.issues.visible.find(params[:id])
end
-
+
@issue.project = @project
# Tracker must be set before custom field values
- @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
+ begin
+ @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
+ rescue ActiveRecord::RecordNotFound
+ @issue.tracker ||= @project.trackers.find(:all).first;
+ end
if @issue.tracker.nil?
render_error l(:error_no_tracker_in_project)
return false
View
35 app/models/issue.rb
@@ -162,8 +162,11 @@ def move_to_project_without_transaction(new_project, new_tracker = nil, options
issue.fixed_version = nil
end
issue.project = new_project
- if issue.parent && issue.parent.project_id != issue.project_id
- issue.parent_issue_id = nil
+ # keep the parent issue dude!
+ unless Setting.cross_project_issue_relations?
+ if issue.parent && issue.parent.project_id != issue.project_id
+ issue.parent_issue_id = nil
+ end
end
end
if new_tracker
@@ -331,31 +334,33 @@ def validate
errors.add_to_base I18n.t(:error_can_not_reopen_issue_on_closed_version)
end
end
-
+
# Checks that the issue can not be added/moved to a disabled tracker
if project && (tracker_id_changed? || project_id_changed?)
unless project.trackers.include?(tracker)
errors.add :tracker_id, :inclusion
end
end
-
+
# Checks parent issue assignment
if @parent_issue
- if @parent_issue.project_id != project_id
- errors.add :parent_issue_id, :not_same_project
- elsif !new_record?
- # moving an existing issue
- if @parent_issue.root_id != root_id
- # we can always move to another tree
- elsif move_possible?(@parent_issue)
- # move accepted inside tree
- else
- errors.add :parent_issue_id, :not_a_valid_parent
+ unless Setting.cross_project_issue_relations?
+ if @parent_issue.project_id != project_id
+ errors.add :parent_issue_id, :not_same_project
+ elsif !new_record?
+ # moving an existing issue
+ if @parent_issue.root_id != root_id
+ # we can always move to another tree
+ elsif move_possible?(@parent_issue)
+ # move accepted inside tree
+ else
+ errors.add :parent_issue_id, :not_a_valid_parent
+ end
end
end
end
end
-
+
# Set the done_ratio using the status if that setting is set. This will keep the done_ratios
# even if the user turns off the setting later
def update_done_ratio_from_issue_status
View
2  app/views/issues/_form.rhtml
@@ -3,7 +3,7 @@
<div id="issue_descr_fields" <%= 'style="display:none"' unless @issue.new_record? || @issue.errors.any? %>>
<p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p>
<%= observe_field :issue_tracker_id, :url => { :action => :new, :project_id => @project, :id => @issue },
- :update => :attributes,
+ :update => :project,
:with => "Form.serialize('issue-form')" %>
<p><%= f.text_field :subject, :size => 80, :required => true %></p>
View
9 app/views/issues/new.rhtml
@@ -4,18 +4,23 @@
:html => {:multipart => true, :id => 'issue-form', :class => 'tabular new-issue-form'} do |f| %>
<%= error_messages_for 'issue' %>
<div class="box">
+ <p><%= f.select "project_id", project_tree_options_for_select(Issue.allowed_target_projects_on_move, :selected => @issue.project), :required => true %></p>
+ <%= observe_field :issue_project_id, :url => { :action => :new, :project_id => @project, :id => @issue },
+ :update => 'content',
+ :with => "Form.serialize('issue-form')" %>
+
<%= render :partial => 'issues/form', :locals => {:f => f} %>
</div>
<%= submit_tag l(:button_create) %>
<%= submit_tag l(:button_create_and_continue), :name => 'continue' %>
- <%= link_to_remote l(:label_preview),
+ <%= link_to_remote l(:label_preview),
{ :url => preview_issue_path(:project_id => @project),
:method => 'post',
:update => 'preview',
:with => "Form.serialize('issue-form')",
:complete => "Element.scrollTo('preview')"
}, :accesskey => accesskey(:preview) %>
-
+
<%= javascript_tag "Form.Element.focus('issue_subject');" %>
<% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.