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', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
+ }
+ end
+ end
end
end
}))
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
<p><label><%=l(:field_status)%></label> <%= @issue.status.name %></p>
<p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
-<p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %></p>
+<p><%= 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') %></p>
</div>
<div class="splitcontentright">
<p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p>
<p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
-<p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %></p>
+<p><%= 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') %></p>
</div>
<div class="splitcontentright">
<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
}
}
+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(){