mirror of
https://github.com/redmine/redmine.git
synced 2024-08-07 21:06:46 +02:00
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
This commit is contained in:
parent
6206c88dfa
commit
c77370a9eb
@ -41,6 +41,17 @@ class IssueCategoriesController < ApplicationController
|
|||||||
def new
|
def new
|
||||||
@category = @project.issue_categories.build
|
@category = @project.issue_categories.build
|
||||||
@category.safe_attributes = params[:issue_category]
|
@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
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@ -53,9 +64,11 @@ class IssueCategoriesController < ApplicationController
|
|||||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
|
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
|
||||||
end
|
end
|
||||||
format.js do
|
format.js do
|
||||||
# IE doesn't support the replace_html rjs method for select box options
|
render(:update) {|page|
|
||||||
render(:update) {|page| page.replace "issue_category_id",
|
page << 'hideModal();'
|
||||||
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]')
|
# 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
|
end
|
||||||
format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
|
format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
|
||||||
@ -64,7 +77,10 @@ class IssueCategoriesController < ApplicationController
|
|||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'new'}
|
format.html { render :action => 'new'}
|
||||||
format.js do
|
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
|
end
|
||||||
format.api { render_validation_errors(@category) }
|
format.api { render_validation_errors(@category) }
|
||||||
end
|
end
|
||||||
|
9
app/views/issue_categories/_new_modal.html.erb
Normal file
9
app/views/issue_categories/_new_modal.html.erb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<h3 class="title"><%=l(:label_issue_category_new)%></h3>
|
||||||
|
|
||||||
|
<%= labelled_remote_form_for @category, :as => 'issue_category', :url => project_issue_categories_path(@project) do |f| %>
|
||||||
|
<%= render :partial => 'issue_categories/form', :locals => { :f => f } %>
|
||||||
|
<p class="buttons">
|
||||||
|
<%= submit_tag l(:button_create), :name => nil %>
|
||||||
|
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
@ -18,12 +18,10 @@
|
|||||||
|
|
||||||
<% if @issue.safe_attribute?('category_id') && @issue.project.issue_categories.any? %>
|
<% if @issue.safe_attribute?('category_id') && @issue.project.issue_categories.any? %>
|
||||||
<p><%= f.select :category_id, (@issue.project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
|
<p><%= f.select :category_id, (@issue.project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
|
||||||
<%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'),
|
<%= link_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'),
|
||||||
l(:label_issue_category_new),
|
{:url => new_project_issue_category_path(@issue.project), :method => 'get'},
|
||||||
'issue_category[name]',
|
:title => l(:label_issue_category_new),
|
||||||
{:controller => 'issue_categories', :action => 'create', :project_id => @issue.project},
|
:tabindex => 200) if User.current.allowed_to?(:manage_categories, @issue.project) %></p>
|
||||||
:title => l(:label_issue_category_new),
|
|
||||||
:tabindex => 199) if User.current.allowed_to?(:manage_categories, @issue.project) %></p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @issue.safe_attribute?('fixed_version_id') && @issue.assignable_versions.any? %>
|
<% if @issue.safe_attribute?('fixed_version_id') && @issue.assignable_versions.any? %>
|
||||||
|
@ -79,7 +79,9 @@ class IssueCategoriesControllerTest < ActionController::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_match /alert/, @response.body
|
assert_select_rjs :replace_html, "ajax-modal" do
|
||||||
|
assert_select "div#errorExplanation"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edit
|
def test_edit
|
||||||
|
Loading…
Reference in New Issue
Block a user