Start removing the RJS stuff.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10043 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-07-19 16:43:33 +00:00
parent 51d5a52029
commit 035805fbd0
8 changed files with 37 additions and 58 deletions

View File

@ -44,13 +44,7 @@ class IssueCategoriesController < ApplicationController
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
format.js
end
end
@ -63,25 +57,13 @@ class IssueCategoriesController < ApplicationController
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
end
format.js do
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.js
format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
end
else
respond_to do |format|
format.html { render :action => 'new'}
format.js do
render :update do |page|
page.replace_html 'ajax-modal', :partial => 'issue_categories/new_modal'
page << "Form.Element.focus('version_name');"
end
end
format.js { render :action => 'new'}
format.api { render_validation_errors(@category) }
end
end

View File

@ -78,13 +78,7 @@ class VersionsController < ApplicationController
respond_to do |format|
format.html
format.js do
render :update do |page|
page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
page << "showModal('ajax-modal', '600px');"
page << "Form.Element.focus('version_name');"
end
end
format.js
end
end
@ -103,14 +97,7 @@ class VersionsController < ApplicationController
flash[:notice] = l(:notice_successful_create)
redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
end
format.js do
render(:update) {|page|
page << 'hideModal();'
# IE doesn't support the replace_html rjs method for select box options
page.replace "issue_fixed_version_id",
content_tag('select', content_tag('option') + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]')
}
end
format.js
format.api do
render :action => 'show', :status => :created, :location => version_url(@version)
end
@ -118,12 +105,7 @@ class VersionsController < ApplicationController
else
respond_to do |format|
format.html { render :action => 'new' }
format.js do
render :update do |page|
page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
page << "Form.Element.focus('version_name');"
end
end
format.js { render :action => 'new' }
format.api { render_validation_errors(@version) }
end
end

View File

@ -0,0 +1,3 @@
hideModal();
<% select = 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]') %>
Element.replace('issue_category_id', '<%= escape_javascript(select) %>');

View File

@ -0,0 +1,3 @@
Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'issue_categories/new_modal') %>');
showModal('ajax-modal', '600px');
Form.Element.focus('issue_category_name');

View File

@ -0,0 +1,3 @@
hideModal();
<% select = content_tag('select', content_tag('option') + version_options_for_select(@project.shared_versions.open, @version), :id => 'issue_fixed_version_id', :name => 'issue[fixed_version_id]') %>
Element.replace('issue_fixed_version_id', '<%= escape_javascript(select) %>');

View File

@ -0,0 +1,3 @@
Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'versions/new_modal') %>');
showModal('ajax-modal', '600px');
Form.Element.focus('version_name');

View File

@ -40,6 +40,15 @@ class IssueCategoriesControllerTest < ActionController::TestCase
assert_select 'input[name=?]', 'issue_category[name]'
end
def test_new_from_issue_form
@request.session[:user_id] = 2 # manager
xhr :get, :new, :project_id => '1'
assert_response :success
assert_template 'new'
assert_equal 'text/javascript', response.content_type
end
def test_create
@request.session[:user_id] = 2 # manager
assert_difference 'IssueCategory.count' do
@ -67,9 +76,8 @@ class IssueCategoriesControllerTest < ActionController::TestCase
assert_equal 'New category', category.name
assert_response :success
assert_select_rjs :replace, 'issue_category_id' do
assert_select "option[value=#{category.id}][selected=selected]"
end
assert_template 'create'
assert_equal 'text/javascript', response.content_type
end
def test_create_from_issue_form_with_failure
@ -79,9 +87,8 @@ class IssueCategoriesControllerTest < ActionController::TestCase
end
assert_response :success
assert_select_rjs :replace_html, "ajax-modal" do
assert_select "div#errorExplanation"
end
assert_template 'new'
assert_equal 'text/javascript', response.content_type
end
def test_edit

View File

@ -100,10 +100,8 @@ class VersionsControllerTest < ActionController::TestCase
@request.session[:user_id] = 2
xhr :get, :new, :project_id => '1'
assert_response :success
assert_select_rjs :replace_html, "ajax-modal" do
assert_select "form[action=/projects/ecookbook/versions]"
assert_select "input#version_name"
end
assert_template 'new'
assert_equal 'text/javascript', response.content_type
end
def test_create
@ -127,9 +125,8 @@ class VersionsControllerTest < ActionController::TestCase
assert_equal 1, version.project_id
assert_response :success
assert_select_rjs :replace, 'issue_fixed_version_id' do
assert_select "option[value=#{version.id}][selected=selected]"
end
assert_template 'create'
assert_equal 'text/javascript', response.content_type
end
def test_create_from_issue_form_with_failure
@ -138,9 +135,8 @@ class VersionsControllerTest < ActionController::TestCase
xhr :post, :create, :project_id => '1', :version => {:name => ''}
end
assert_response :success
assert_select_rjs :replace_html, "ajax-modal" do
assert_select "div#errorExplanation"
end
assert_template 'new'
assert_equal 'text/javascript', response.content_type
end
def test_get_edit