diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-20 15:55:19 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-11-20 15:55:19 +0000 |
commit | 6f4fb8b8920cc8bd414e98671b6025a4378d6c25 (patch) | |
tree | 4548c25ff2e01c12ee41fdbf39b365e49ec71217 /app/controllers/issue_categories_controller.rb | |
parent | 30556f8cbfac04d5d6c6e3a9331874b7e83954d6 (diff) | |
download | redmine-6f4fb8b8920cc8bd414e98671b6025a4378d6c25.tar.gz redmine-6f4fb8b8920cc8bd414e98671b6025a4378d6c25.zip |
Resourcified issue categories (#9553).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7881 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/issue_categories_controller.rb')
-rw-r--r-- | app/controllers/issue_categories_controller.rb | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb index 59e69ad98..b0d11dd8f 100644 --- a/app/controllers/issue_categories_controller.rb +++ b/app/controllers/issue_categories_controller.rb @@ -18,47 +18,55 @@ class IssueCategoriesController < ApplicationController menu_item :settings model_object IssueCategory - before_filter :find_model_object, :except => :new - before_filter :find_project_from_association, :except => :new - before_filter :find_project, :only => :new + before_filter :find_model_object, :except => [:new, :create] + before_filter :find_project_from_association, :except => [:new, :create] + before_filter :find_project, :only => [:new, :create] 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 + + verify :method => :post, :only => :create + def create + @category = @project.issue_categories.build(params[:category]) + 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 - else - respond_to do |format| - format.html - format.js do - render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) } - 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 { render :action => 'new'} + format.js do + render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) } end end end end def edit - if request.post? and @category.update_attributes(params[:category]) + end + + verify :method => :put, :only => :update + def update + if @category.update_attributes(params[:category]) flash[:notice] = l(:notice_successful_update) redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project + else + render :action => 'edit' end end + verify :method => :delete, :only => :destroy def destroy @issue_count = @category.issues.size if @issue_count == 0 |