summaryrefslogtreecommitdiffstats
path: root/app/controllers/issue_categories_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-15 16:52:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-15 16:52:32 +0000
commitfa969504d4529ca9b2ceadf3c56f09b171c9170e (patch)
treeb0f3feff09ffafd1c5d8339b228eab4e18fedb3f /app/controllers/issue_categories_controller.rb
parent3c6ddc9cecc250b3853025ca8b10a964bed0ff97 (diff)
downloadredmine-fa969504d4529ca9b2ceadf3c56f09b171c9170e.tar.gz
redmine-fa969504d4529ca9b2ceadf3c56f09b171c9170e.zip
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
Diffstat (limited to 'app/controllers/issue_categories_controller.rb')
-rw-r--r--app/controllers/issue_categories_controller.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb
index 29a3f02af..2c1c6657b 100644
--- a/app/controllers/issue_categories_controller.rb
+++ b/app/controllers/issue_categories_controller.rb
@@ -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