diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 582ff33..920dbd5 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -169,8 +169,18 @@ class ProjectsController < ApplicationController def add_issue_category @category = @project.issue_categories.build(params[:category]) if request.post? and @category.save - flash[:notice] = l(:notice_successful_create) - redirect_to :action => 'settings', :tab => 'categories', :id => @project + respond_to do |format| + format.html do + flash[:notice] = l(:notice_successful_create) + redirect_to :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', '' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') + } + end + end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1563106..0719044 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -77,6 +77,11 @@ module ApplicationHelper })) end + def prompt_to_remote(name, text, param, url, html_options = {}) + html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;" + link_to name, {}, html_options + end + def format_date(date) return nil unless date @date_format_setting ||= Setting.date_format.to_i diff --git a/app/views/issues/edit.rhtml b/app/views/issues/edit.rhtml index 05017ac..18d6e01 100644 --- a/app/views/issues/edit.rhtml +++ b/app/views/issues/edit.rhtml @@ -8,7 +8,11 @@
<%= @issue.status.name %>
<%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %>
<%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %>
-<%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
+<%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %> +<%= prompt_to_remote(l(:label_issue_category_new), + l(:label_issue_category_new), 'category[name]', + {:controller => 'projects', :action => 'add_issue_category', :id => @project}, + :class => 'small') if authorize_for('projects', 'add_issue_category') %>
<%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %>
<%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %>
<%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %>
-<%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
+<%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %> +<%= prompt_to_remote(l(:label_issue_category_new), + l(:label_issue_category_new), 'category[name]', + {:controller => 'projects', :action => 'add_issue_category', :id => @project}, + :class => 'small') if authorize_for('projects', 'add_issue_category') %>
<%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %>
diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 7ca0cc4..6a30e42 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -41,6 +41,14 @@ function setPredecessorFieldsVisibility() { } } +function promptToRemote(text, param, url) { + value = prompt(text + ':'); + if (value) { + new Ajax.Request(url + '?' + param + '=' + value, {asynchronous:true, evalScripts:true}); + return false; + } +} + /* shows and hides ajax indicator */ Ajax.Responders.register({ onCreate: function(){