@@ -21,7 +21,7 class IssuesController < ApplicationController | |||||
21 |
|
21 | |||
22 | before_filter :find_issue, :only => [:show, :edit, :update] |
|
22 | before_filter :find_issue, :only => [:show, :edit, :update] | |
23 | before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy] |
|
23 | before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy] | |
24 |
before_filter :find_project, :only => [:new, :create |
|
24 | before_filter :find_project, :only => [:new, :create] | |
25 | before_filter :authorize, :except => [:index, :changes] |
|
25 | before_filter :authorize, :except => [:index, :changes] | |
26 | before_filter :find_optional_project, :only => [:index, :changes] |
|
26 | before_filter :find_optional_project, :only => [:index, :changes] | |
27 | before_filter :check_for_default_issue_status, :only => [:new, :create] |
|
27 | before_filter :check_for_default_issue_status, :only => [:new, :create] | |
@@ -132,7 +132,10 class IssuesController < ApplicationController | |||||
132 | # Add a new issue |
|
132 | # Add a new issue | |
133 | # The new issue will be created from an existing one if copy_from parameter is given |
|
133 | # The new issue will be created from an existing one if copy_from parameter is given | |
134 | def new |
|
134 | def new | |
135 | render :action => 'new', :layout => !request.xhr? |
|
135 | respond_to do |format| | |
|
136 | format.html { render :action => 'new', :layout => !request.xhr? } | |||
|
137 | format.js { render :partial => 'attributes' } | |||
|
138 | end | |||
136 | end |
|
139 | end | |
137 |
|
140 | |||
138 | def create |
|
141 | def create | |
@@ -258,20 +261,6 class IssuesController < ApplicationController | |||||
258 | end |
|
261 | end | |
259 | end |
|
262 | end | |
260 |
|
263 | |||
261 | def update_form |
|
|||
262 | if params[:id].blank? |
|
|||
263 | @issue = Issue.new |
|
|||
264 | @issue.project = @project |
|
|||
265 | else |
|
|||
266 | @issue = @project.issues.visible.find(params[:id]) |
|
|||
267 | end |
|
|||
268 | @issue.attributes = params[:issue] |
|
|||
269 | @allowed_statuses = ([@issue.status] + @issue.status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq |
|
|||
270 | @priorities = IssuePriority.all |
|
|||
271 |
|
||||
272 | render :partial => 'attributes' |
|
|||
273 | end |
|
|||
274 |
|
||||
275 | private |
|
264 | private | |
276 | def find_issue |
|
265 | def find_issue | |
277 | @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) |
|
266 | @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) | |
@@ -310,8 +299,14 private | |||||
310 |
|
299 | |||
311 | # TODO: Refactor, lots of extra code in here |
|
300 | # TODO: Refactor, lots of extra code in here | |
312 | def build_new_issue_from_params |
|
301 | def build_new_issue_from_params | |
313 | @issue = Issue.new |
|
302 | if params[:id].blank? | |
314 | @issue.copy_from(params[:copy_from]) if params[:copy_from] |
|
303 | @issue = Issue.new | |
|
304 | @issue.copy_from(params[:copy_from]) if params[:copy_from] | |||
|
305 | @issue.project = @project | |||
|
306 | else | |||
|
307 | @issue = @project.issues.visible.find(params[:id]) | |||
|
308 | end | |||
|
309 | ||||
315 | @issue.project = @project |
|
310 | @issue.project = @project | |
316 | # Tracker must be set before custom field values |
|
311 | # Tracker must be set before custom field values | |
317 | @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) |
|
312 | @issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) |
@@ -1,6 +1,6 | |||||
1 | <div id="issue_descr_fields" <%= 'style="display:none"' unless @issue.new_record? || @issue.errors.any? %>> |
|
1 | <div id="issue_descr_fields" <%= 'style="display:none"' unless @issue.new_record? || @issue.errors.any? %>> | |
2 | <p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p> |
|
2 | <p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p> | |
3 |
<%= observe_field :issue_tracker_id, :url => { :action => : |
|
3 | <%= observe_field :issue_tracker_id, :url => { :action => :new, :project_id => @project, :id => @issue }, | |
4 | :update => :attributes, |
|
4 | :update => :attributes, | |
5 | :with => "Form.serialize('issue-form')" %> |
|
5 | :with => "Form.serialize('issue-form')" %> | |
6 |
|
6 |
@@ -365,7 +365,7 class IssuesControllerTest < ActionController::TestCase | |||||
365 |
|
365 | |||
366 | def test_update_new_form |
|
366 | def test_update_new_form | |
367 | @request.session[:user_id] = 2 |
|
367 | @request.session[:user_id] = 2 | |
368 |
xhr :post, : |
|
368 | xhr :post, :new, :project_id => 1, | |
369 | :issue => {:tracker_id => 2, |
|
369 | :issue => {:tracker_id => 2, | |
370 | :subject => 'This is the test_new issue', |
|
370 | :subject => 'This is the test_new issue', | |
371 | :description => 'This is the description', |
|
371 | :description => 'This is the description', | |
@@ -617,7 +617,7 class IssuesControllerTest < ActionController::TestCase | |||||
617 |
|
617 | |||
618 | def test_update_edit_form |
|
618 | def test_update_edit_form | |
619 | @request.session[:user_id] = 2 |
|
619 | @request.session[:user_id] = 2 | |
620 |
xhr :post, : |
|
620 | xhr :post, :new, :project_id => 1, | |
621 | :id => 1, |
|
621 | :id => 1, | |
622 | :issue => {:tracker_id => 2, |
|
622 | :issue => {:tracker_id => 2, | |
623 | :subject => 'This is the test_new issue', |
|
623 | :subject => 'This is the test_new issue', |
General Comments 0
You need to be logged in to leave comments.
Login now