@@ -0,0 +1,34 | |||||
|
1 | <% fields_for :issue, @issue, :builder => TabularFormBuilder do |f| %> | |||
|
2 | ||||
|
3 | <div class="splitcontentleft"> | |||
|
4 | <% if @issue.new_record? || @allowed_statuses.any? %> | |||
|
5 | <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p> | |||
|
6 | <% else %> | |||
|
7 | <p><label><%= l(:field_status) %></label> <%= @issue.status.name %></p> | |||
|
8 | <% end %> | |||
|
9 | ||||
|
10 | <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p> | |||
|
11 | <p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p> | |||
|
12 | <% unless @project.issue_categories.empty? %> | |||
|
13 | <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %> | |||
|
14 | <%= prompt_to_remote(l(:label_issue_category_new), | |||
|
15 | l(:label_issue_category_new), 'category[name]', | |||
|
16 | {:controller => 'projects', :action => 'add_issue_category', :id => @project}, | |||
|
17 | :class => 'small', :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p> | |||
|
18 | <% end %> | |||
|
19 | <% unless @issue.assignable_versions.empty? %> | |||
|
20 | <p><%= f.select :fixed_version_id, (@issue.assignable_versions.collect {|v| [v.name, v.id]}), :include_blank => true %></p> | |||
|
21 | <% end %> | |||
|
22 | </div> | |||
|
23 | ||||
|
24 | <div class="splitcontentright"> | |||
|
25 | <p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p> | |||
|
26 | <p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p> | |||
|
27 | <p><%= f.text_field :estimated_hours, :size => 3 %> <%= l(:field_hours) %></p> | |||
|
28 | <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p> | |||
|
29 | </div> | |||
|
30 | ||||
|
31 | <div style="clear:both;"> </div> | |||
|
32 | <%= render :partial => 'form_custom_fields' %> | |||
|
33 | ||||
|
34 | <% end %> |
@@ -22,7 +22,7 class IssuesController < ApplicationController | |||||
22 | before_filter :find_issue, :only => [:show, :edit, :reply] |
|
22 | before_filter :find_issue, :only => [:show, :edit, :reply] | |
23 | before_filter :find_issues, :only => [:bulk_edit, :move, :destroy] |
|
23 | before_filter :find_issues, :only => [:bulk_edit, :move, :destroy] | |
24 | before_filter :find_project, :only => [:new, :update_form, :preview] |
|
24 | before_filter :find_project, :only => [:new, :update_form, :preview] | |
25 |
before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, |
|
25 | before_filter :authorize, :except => [:index, :changes, :gantt, :calendar, :preview, :context_menu] | |
26 | before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar] |
|
26 | before_filter :find_optional_project, :only => [:index, :changes, :gantt, :calendar] | |
27 | accept_key_auth :index, :show, :changes |
|
27 | accept_key_auth :index, :show, :changes | |
28 |
|
28 | |||
@@ -429,8 +429,17 class IssuesController < ApplicationController | |||||
429 | end |
|
429 | end | |
430 |
|
430 | |||
431 | def update_form |
|
431 | def update_form | |
432 | @issue = Issue.new(params[:issue]) |
|
432 | if params[:id] | |
433 | render :action => :new, :layout => false |
|
433 | @issue = @project.issues.visible.find(params[:id]) | |
|
434 | else | |||
|
435 | @issue = Issue.new | |||
|
436 | @issue.project = @project | |||
|
437 | end | |||
|
438 | @issue.attributes = params[:issue] | |||
|
439 | @allowed_statuses = ([@issue.status] + @issue.status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq | |||
|
440 | @priorities = IssuePriority.all | |||
|
441 | ||||
|
442 | render :partial => 'attributes' | |||
434 | end |
|
443 | end | |
435 |
|
444 | |||
436 | def preview |
|
445 | def preview |
@@ -127,6 +127,11 class Issue < ActiveRecord::Base | |||||
127 | self.priority = nil |
|
127 | self.priority = nil | |
128 | write_attribute(:priority_id, pid) |
|
128 | write_attribute(:priority_id, pid) | |
129 | end |
|
129 | end | |
|
130 | ||||
|
131 | def tracker_id=(tid) | |||
|
132 | self.tracker = nil | |||
|
133 | write_attribute(:tracker_id, tid) | |||
|
134 | end | |||
130 |
|
135 | |||
131 | def estimated_hours=(h) |
|
136 | def estimated_hours=(h) | |
132 | write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h) |
|
137 | write_attribute :estimated_hours, (h.is_a?(String) ? h.to_hours : h) | |
@@ -152,6 +157,13 class Issue < ActiveRecord::Base | |||||
152 | errors.add_to_base I18n.t(:error_can_not_reopen_issue_on_closed_version) |
|
157 | errors.add_to_base I18n.t(:error_can_not_reopen_issue_on_closed_version) | |
153 | end |
|
158 | end | |
154 | end |
|
159 | end | |
|
160 | ||||
|
161 | # Checks that the issue can not be added/moved to a disabled tracker | |||
|
162 | if project && (tracker_id_changed? || project_id_changed?) | |||
|
163 | unless project.trackers.include?(tracker) | |||
|
164 | errors.add :tracker_id, :inclusion | |||
|
165 | end | |||
|
166 | end | |||
155 | end |
|
167 | end | |
156 |
|
168 | |||
157 | def validate_on_create |
|
169 | def validate_on_create |
@@ -1,12 +1,9 | |||||
1 | <% if @issue.new_record? %> |
|
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 => :update_form, :project_id => @project, :id => @issue }, | |
4 |
:update => : |
|
4 | :update => :attributes, | |
5 | :with => "Form.serialize('issue-form')" %> |
|
5 | :with => "Form.serialize('issue-form')" %> | |
6 | <hr /> |
|
|||
7 | <% end %> |
|
|||
8 |
|
6 | |||
9 | <div id="issue_descr_fields" <%= 'style="display:none"' unless @issue.new_record? || @issue.errors.any? %>> |
|
|||
10 | <p><%= f.text_field :subject, :size => 80, :required => true %></p> |
|
7 | <p><%= f.text_field :subject, :size => 80, :required => true %></p> | |
11 | <p><%= f.text_area :description, |
|
8 | <p><%= f.text_area :description, | |
12 | :cols => 60, |
|
9 | :cols => 60, | |
@@ -15,37 +12,8 | |||||
15 | :class => 'wiki-edit' %></p> |
|
12 | :class => 'wiki-edit' %></p> | |
16 | </div> |
|
13 | </div> | |
17 |
|
14 | |||
18 | <div class="attributes"> |
|
15 | <div id="attributes" class="attributes"> | |
19 | <div class="splitcontentleft"> |
|
16 | <%= render :partial => 'attributes' %> | |
20 | <% if @issue.new_record? || @allowed_statuses.any? %> |
|
|||
21 | <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p> |
|
|||
22 | <% else %> |
|
|||
23 | <p><label><%= l(:field_status) %></label> <%= @issue.status.name %></p> |
|
|||
24 | <% end %> |
|
|||
25 |
|
||||
26 | <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p> |
|
|||
27 | <p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p> |
|
|||
28 | <% unless @project.issue_categories.empty? %> |
|
|||
29 | <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %> |
|
|||
30 | <%= prompt_to_remote(l(:label_issue_category_new), |
|
|||
31 | l(:label_issue_category_new), 'category[name]', |
|
|||
32 | {:controller => 'projects', :action => 'add_issue_category', :id => @project}, |
|
|||
33 | :class => 'small', :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p> |
|
|||
34 | <% end %> |
|
|||
35 | <% unless @issue.assignable_versions.empty? %> |
|
|||
36 | <p><%= f.select :fixed_version_id, (@issue.assignable_versions.collect {|v| [v.name, v.id]}), :include_blank => true %></p> |
|
|||
37 | <% end %> |
|
|||
38 | </div> |
|
|||
39 |
|
||||
40 | <div class="splitcontentright"> |
|
|||
41 | <p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p> |
|
|||
42 | <p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p> |
|
|||
43 | <p><%= f.text_field :estimated_hours, :size => 3 %> <%= l(:field_hours) %></p> |
|
|||
44 | <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p> |
|
|||
45 | </div> |
|
|||
46 |
|
||||
47 | <div style="clear:both;"> </div> |
|
|||
48 | <%= render :partial => 'form_custom_fields' %> |
|
|||
49 | </div> |
|
17 | </div> | |
50 |
|
18 | |||
51 | <% if @issue.new_record? %> |
|
19 | <% if @issue.new_record? %> |
@@ -42,8 +42,8 Redmine::AccessControl.map do |map| | |||||
42 | :versions => [:show, :status_by], |
|
42 | :versions => [:show, :status_by], | |
43 | :queries => :index, |
|
43 | :queries => :index, | |
44 | :reports => :issue_report} |
|
44 | :reports => :issue_report} | |
45 | map.permission :add_issues, {:issues => :new} |
|
45 | map.permission :add_issues, {:issues => [:new, :update_form]} | |
46 | map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit]} |
|
46 | map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit, :update_form]} | |
47 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} |
|
47 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} | |
48 | map.permission :add_issue_notes, {:issues => [:edit, :reply]} |
|
48 | map.permission :add_issue_notes, {:issues => [:edit, :reply]} | |
49 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
|
49 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
@@ -501,14 +501,20 class IssuesControllerTest < ActionController::TestCase | |||||
501 |
|
501 | |||
502 | def test_update_new_form |
|
502 | def test_update_new_form | |
503 | @request.session[:user_id] = 2 |
|
503 | @request.session[:user_id] = 2 | |
504 |
xhr :post, : |
|
504 | xhr :post, :update_form, :project_id => 1, | |
505 | :issue => {:tracker_id => 2, |
|
505 | :issue => {:tracker_id => 2, | |
506 | :subject => 'This is the test_new issue', |
|
506 | :subject => 'This is the test_new issue', | |
507 | :description => 'This is the description', |
|
507 | :description => 'This is the description', | |
508 | :priority_id => 5} |
|
508 | :priority_id => 5} | |
509 | assert_response :success |
|
509 | assert_response :success | |
510 |
assert_template ' |
|
510 | assert_template 'attributes' | |
511 |
|
|
511 | ||
|
512 | issue = assigns(:issue) | |||
|
513 | assert_kind_of Issue, issue | |||
|
514 | assert_equal 1, issue.project_id | |||
|
515 | assert_equal 2, issue.tracker_id | |||
|
516 | assert_equal 'This is the test_new issue', issue.subject | |||
|
517 | end | |||
512 |
|
518 | |||
513 | def test_post_new |
|
519 | def test_post_new | |
514 | @request.session[:user_id] = 2 |
|
520 | @request.session[:user_id] = 2 | |
@@ -698,6 +704,25 class IssuesControllerTest < ActionController::TestCase | |||||
698 | :content => 'Urgent', |
|
704 | :content => 'Urgent', | |
699 | :attributes => { :selected => 'selected' } } |
|
705 | :attributes => { :selected => 'selected' } } | |
700 | end |
|
706 | end | |
|
707 | ||||
|
708 | def test_update_edit_form | |||
|
709 | @request.session[:user_id] = 2 | |||
|
710 | xhr :post, :update_form, :project_id => 1, | |||
|
711 | :id => 1, | |||
|
712 | :issue => {:tracker_id => 2, | |||
|
713 | :subject => 'This is the test_new issue', | |||
|
714 | :description => 'This is the description', | |||
|
715 | :priority_id => 5} | |||
|
716 | assert_response :success | |||
|
717 | assert_template 'attributes' | |||
|
718 | ||||
|
719 | issue = assigns(:issue) | |||
|
720 | assert_kind_of Issue, issue | |||
|
721 | assert_equal 1, issue.id | |||
|
722 | assert_equal 1, issue.project_id | |||
|
723 | assert_equal 2, issue.tracker_id | |||
|
724 | assert_equal 'This is the test_new issue', issue.subject | |||
|
725 | end | |||
701 |
|
726 | |||
702 | def test_reply_routing |
|
727 | def test_reply_routing | |
703 | assert_routing( |
|
728 | assert_routing( |
@@ -164,6 +164,29 class IssueTest < ActiveSupport::TestCase | |||||
164 | assert_equal custom_value.id, issue.custom_value_for(field).id |
|
164 | assert_equal custom_value.id, issue.custom_value_for(field).id | |
165 | end |
|
165 | end | |
166 |
|
166 | |||
|
167 | def test_should_update_issue_with_disabled_tracker | |||
|
168 | p = Project.find(1) | |||
|
169 | issue = Issue.find(1) | |||
|
170 | ||||
|
171 | p.trackers.delete(issue.tracker) | |||
|
172 | assert !p.trackers.include?(issue.tracker) | |||
|
173 | ||||
|
174 | issue.reload | |||
|
175 | issue.subject = 'New subject' | |||
|
176 | assert issue.save | |||
|
177 | end | |||
|
178 | ||||
|
179 | def test_should_not_set_a_disabled_tracker | |||
|
180 | p = Project.find(1) | |||
|
181 | p.trackers.delete(Tracker.find(2)) | |||
|
182 | ||||
|
183 | issue = Issue.find(1) | |||
|
184 | issue.tracker_id = 2 | |||
|
185 | issue.subject = 'New subject' | |||
|
186 | assert !issue.save | |||
|
187 | assert_not_nil issue.errors.on(:tracker_id) | |||
|
188 | end | |||
|
189 | ||||
167 | def test_category_based_assignment |
|
190 | def test_category_based_assignment | |
168 | issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1) |
|
191 | issue = Issue.create(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'Assignment test', :description => 'Assignment test', :category_id => 1) | |
169 | assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to |
|
192 | assert_equal IssueCategory.find(1).assigned_to, issue.assigned_to |
General Comments 0
You need to be logged in to leave comments.
Login now