A category with assigned issue can now be deleted. 2 options are proposed:

* remove assignments (issues are set to 'no category')
* reassign issues to another category (if at least an other category exists)
If no issue is assigned to the category, it's deleted silently.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@733 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2007-09-15 16:52:32 +00:00
parent 3c6ddc9cec
commit fa969504d4
17 changed files with 117 additions and 11 deletions
+13 -5
View File
@@ -18,6 +18,8 @@
class IssueCategoriesController < ApplicationController
layout 'base'
before_filter :find_project, :authorize
verify :method => :post, :only => :destroy
def edit
if request.post? and @category.update_attributes(params[:category])
@@ -27,11 +29,17 @@ class IssueCategoriesController < ApplicationController
end
def destroy
@category.destroy
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
rescue
flash[:error] = "Categorie can't be deleted"
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
@issue_count = @category.issues.size
if @issue_count == 0
# No issue assigned to this category
@category.destroy
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
elsif params[:todo]
reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
@category.destroy(reassign_to)
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
end
@categories = @project.issue_categories - [@category]
end
private