summaryrefslogtreecommitdiffstats
path: root/app/controllers/issue_categories_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/issue_categories_controller.rb')
-rw-r--r--app/controllers/issue_categories_controller.rb39
1 files changed, 37 insertions, 2 deletions
diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb
index 8315d6eb8..8c077cf7a 100644
--- a/app/controllers/issue_categories_controller.rb
+++ b/app/controllers/issue_categories_controller.rb
@@ -17,10 +17,39 @@
class IssueCategoriesController < ApplicationController
menu_item :settings
- before_filter :find_project, :authorize
+ before_filter :find_category, :except => :new
+ before_filter :find_project, :only => :new
+ before_filter :authorize
verify :method => :post, :only => :destroy
+ def new
+ @category = @project.issue_categories.build(params[:category])
+ if request.post?
+ if @category.save
+ respond_to do |format|
+ format.html do
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
+ end
+ format.js do
+ # IE doesn't support the replace_html rjs method for select box options
+ render(:update) {|page| page.replace "issue_category_id",
+ content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
+ }
+ end
+ end
+ else
+ respond_to do |format|
+ format.html
+ format.js do
+ render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) }
+ end
+ end
+ end
+ end
+ end
+
def edit
if request.post? and @category.update_attributes(params[:category])
flash[:notice] = l(:notice_successful_update)
@@ -43,10 +72,16 @@ class IssueCategoriesController < ApplicationController
end
private
- def find_project
+ def find_category
@category = IssueCategory.find(params[:id])
@project = @category.project
rescue ActiveRecord::RecordNotFound
render_404
end
+
+ def find_project
+ @project = Project.find(params[:project_id])
+ rescue ActiveRecord::RecordNotFound
+ render_404
+ end
end