diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-03-06 18:43:00 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2010-03-06 18:43:00 +0000 |
commit | 6511e9423340c297c49cb54521a2fc763d625727 (patch) | |
tree | d2416d6effb08bf09927d73d6f2b38b70068cdb7 /app/controllers/issue_categories_controller.rb | |
parent | 729bea1cf38ed80bc34c47a8ef3783d9e06ce5c5 (diff) | |
download | redmine-6511e9423340c297c49cb54521a2fc763d625727.tar.gz redmine-6511e9423340c297c49cb54521a2fc763d625727.zip |
Moves ProjectsController#add_issue_category to IssueCategoriesController#new.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3549 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/issue_categories_controller.rb')
-rw-r--r-- | app/controllers/issue_categories_controller.rb | 39 |
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 |