diff --git a/redmine/app/controllers/projects_controller.rb b/redmine/app/controllers/projects_controller.rb index 802573054..8343c7a5f 100644 --- a/redmine/app/controllers/projects_controller.rb +++ b/redmine/app/controllers/projects_controller.rb @@ -239,6 +239,30 @@ class ProjectsController < ApplicationController :filename => 'export.csv') end + def move_issues + @issues = @project.issues.find(params[:issue_ids]) if params[:issue_ids] + redirect_to :action => 'list_issues', :id => @project and return unless @issues + @projects = [] + # find projects to which the user is allowed to move the issue + @logged_in_user.memberships.each {|m| @projects << m.project if Permission.allowed_to_role("projects/move_issues", m.role_id)} + # issue can be moved to any tracker + @trackers = Tracker.find(:all) + if request.post? and params[:new_project_id] and params[:new_tracker_id] + new_project = Project.find(params[:new_project_id]) + new_tracker = Tracker.find(params[:new_tracker_id]) + @issues.each { |i| + # category is project dependent + i.category = nil unless i.project_id == new_project.id + # move the issue + i.project = new_project + i.tracker = new_tracker + i.save + } + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'list_issues', :id => @project + end + end + # Add a news to @project def add_news @news = News.new(:project => @project) diff --git a/redmine/app/models/issue.rb b/redmine/app/models/issue.rb index 7b48182c7..489dad885 100644 --- a/redmine/app/models/issue.rb +++ b/redmine/app/models/issue.rb @@ -41,7 +41,7 @@ class Issue < ActiveRecord::Base end def validate - if self.due_date.nil? && !@attributes['due_date'].empty? + if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty? errors.add :due_date, :activerecord_error_not_a_date end end diff --git a/redmine/app/views/issues/show.rhtml b/redmine/app/views/issues/show.rhtml index fc48e47a1..1258a050c 100644 --- a/redmine/app/views/issues/show.rhtml +++ b/redmine/app/views/issues/show.rhtml @@ -35,6 +35,14 @@ <% end %> +<% if authorize_for('projects', 'move_issues') %> + <%= start_form_tag ({:controller => 'projects', :action => 'move_issues', :id => @project} ) %> + <%= hidden_field_tag "issue_ids[]", @issue.id %> + <%= submit_tag l(:button_move) %> + <%= end_form_tag %> + +<% end %> + <% if authorize_for('issues', 'destroy') %> <%= start_form_tag ({:controller => 'issues', :action => 'destroy', :id => @issue} ) %> <%= submit_tag l(:button_delete) %> diff --git a/redmine/app/views/projects/add_issue.rhtml b/redmine/app/views/projects/add_issue.rhtml index f12542b43..11e61d6b3 100644 --- a/redmine/app/views/projects/add_issue.rhtml +++ b/redmine/app/views/projects/add_issue.rhtml @@ -8,7 +8,7 @@
<%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %>
<%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %>
-<%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}) %>
+<%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
<%= f.text_field :subject, :size => 80, :required => true %>
<%= f.text_area :description, :cols => 60, :rows => 10, :required => true %>
<%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %>
diff --git a/redmine/app/views/projects/list_issues.rhtml b/redmine/app/views/projects/list_issues.rhtml index d18799acf..7a924b134 100644 --- a/redmine/app/views/projects/list_issues.rhtml +++ b/redmine/app/views/projects/list_issues.rhtml @@ -22,11 +22,15 @@ + +<%= start_form_tag ({:controller => 'projects', :action => 'move_issues', :id => @project}, :id => 'issues_form' ) %>| - <%= link_to l(:label_export_csv), :action => 'export_issues_csv', :id => @project.id %> - | |||||||
| <%= check_all_links 'issues_form' %> | +<%= link_to l(:label_export_csv), :action => 'export_issues_csv', :id => @project.id %> | +||||||
| <%= sort_header_tag('issues.id', :caption => '#') %> <%= sort_header_tag('issue_statuses.name', :caption => l(:field_status)) %> <%= sort_header_tag('issues.tracker_id', :caption => l(:field_tracker)) %> @@ -37,6 +41,7 @@ | |||||||
| <%= check_box_tag "issue_ids[]", issue.id %> | <%= link_to issue.long_id, :controller => 'issues', :action => 'show', :id => issue %> | <%= issue.status.name %> | <%= issue.tracker.name %> | @@ -50,4 +55,6 @@||||