diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-05-24 17:31:53 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-05-24 17:31:53 +0000 |
commit | c77370a9ebd58dedac42ae0a7b8a045650f80ebc (patch) | |
tree | 2d0c26c8a967c6db161ef6e1857f5ceb97f5c807 /app/controllers | |
parent | 6206c88dfabf4b320ab35026c2833dbb4e9a593c (diff) | |
download | redmine-c77370a9ebd58dedac42ae0a7b8a045650f80ebc.tar.gz redmine-c77370a9ebd58dedac42ae0a7b8a045650f80ebc.zip |
Use a modal form to create a category from the issue form.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9707 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/issue_categories_controller.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/app/controllers/issue_categories_controller.rb b/app/controllers/issue_categories_controller.rb index 81928ff53..36a22b324 100644 --- a/app/controllers/issue_categories_controller.rb +++ b/app/controllers/issue_categories_controller.rb @@ -41,6 +41,17 @@ class IssueCategoriesController < ApplicationController def new @category = @project.issue_categories.build @category.safe_attributes = params[:issue_category] + + respond_to do |format| + format.html + format.js do + render :update do |page| + page.replace_html 'ajax-modal', :partial => 'issue_categories/new_modal' + page << "showModal('ajax-modal', '600px');" + page << "Form.Element.focus('issue_category_name');" + end + end + end end def create @@ -53,9 +64,11 @@ class IssueCategoriesController < ApplicationController 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', content_tag('option') + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') + render(:update) {|page| + page << 'hideModal();' + # IE doesn't support the replace_html rjs method for select box options + page.replace "issue_category_id", + content_tag('select', content_tag('option') + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') } end format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) } @@ -64,7 +77,10 @@ class IssueCategoriesController < ApplicationController respond_to do |format| format.html { render :action => 'new'} format.js do - render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) } + render :update do |page| + page.replace_html 'ajax-modal', :partial => 'issue_categories/new_modal' + page << "Form.Element.focus('version_name');" + end end format.api { render_validation_errors(@category) } end |