Added a link to add a new category when creating or editing an issue.
The user is prompted for the category name. The new category is created and the drop-down list updated using an ajax call. git-svn-id: http://redmine.rubyforge.org/svn/trunk@648 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1f991c6a79
commit
4cedecad4d
|
@ -169,8 +169,18 @@ class ProjectsController < ApplicationController
|
||||||
def add_issue_category
|
def add_issue_category
|
||||||
@category = @project.issue_categories.build(params[:category])
|
@category = @project.issue_categories.build(params[:category])
|
||||||
if request.post? and @category.save
|
if request.post? and @category.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
respond_to do |format|
|
||||||
redirect_to :action => 'settings', :tab => 'categories', :id => @project
|
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
|
end
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,11 @@ module ApplicationHelper
|
||||||
}))
|
}))
|
||||||
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)
|
def format_date(date)
|
||||||
return nil unless date
|
return nil unless date
|
||||||
@date_format_setting ||= Setting.date_format.to_i
|
@date_format_setting ||= Setting.date_format.to_i
|
||||||
|
|
|
@ -8,7 +8,11 @@
|
||||||
<p><label><%=l(:field_status)%></label> <%= @issue.status.name %></p>
|
<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 :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 :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>
|
||||||
|
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
|
|
|
@ -10,7 +10,11 @@
|
||||||
<p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p>
|
<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 :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 :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>
|
||||||
<div class="splitcontentright">
|
<div class="splitcontentright">
|
||||||
<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
|
<p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
|
||||||
|
|
|
@ -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 */
|
/* shows and hides ajax indicator */
|
||||||
Ajax.Responders.register({
|
Ajax.Responders.register({
|
||||||
onCreate: function(){
|
onCreate: function(){
|
||||||
|
|
Loading…
Reference in New Issue