]> source.dussan.org Git - redmine.git/commitdiff
Start removing the RJS stuff.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 19 Jul 2012 16:43:33 +0000 (16:43 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 19 Jul 2012 16:43:33 +0000 (16:43 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10043 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issue_categories_controller.rb
app/controllers/versions_controller.rb
app/views/issue_categories/create.js.erb [new file with mode: 0644]
app/views/issue_categories/new.js.erb [new file with mode: 0644]
app/views/versions/create.js.erb [new file with mode: 0644]
app/views/versions/new.js.erb [new file with mode: 0644]
test/functional/issue_categories_controller_test.rb
test/functional/versions_controller_test.rb

index ecb4bc906a7d3157b8f3596635c88b7f9904f825..e314856e179f77a6e8dc50f759dd516d56d502f0 100644 (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
index dcee97c85b5e71cfed33a114db4eb857c7b83a77..8b9c0acd339db83bfde1b5c98b821d4ced8a2c1a 100644 (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
diff --git a/app/views/issue_categories/create.js.erb b/app/views/issue_categories/create.js.erb
new file mode 100644 (file)
index 0000000..b9cc577
--- /dev/null
@@ -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) %>');
diff --git a/app/views/issue_categories/new.js.erb b/app/views/issue_categories/new.js.erb
new file mode 100644 (file)
index 0000000..2a28e38
--- /dev/null
@@ -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');
diff --git a/app/views/versions/create.js.erb b/app/views/versions/create.js.erb
new file mode 100644 (file)
index 0000000..01720bf
--- /dev/null
@@ -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) %>');
diff --git a/app/views/versions/new.js.erb b/app/views/versions/new.js.erb
new file mode 100644 (file)
index 0000000..cce80e0
--- /dev/null
@@ -0,0 +1,3 @@
+Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'versions/new_modal') %>');
+showModal('ajax-modal', '600px');
+Form.Element.focus('version_name');
index 5c9e6c9dcac083e70761368c640d9b04300f325f..8364e11f1cfaa9bdb214cb121c725f4e5191a14d 100644 (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
index 0aa490a662e796ebeb39e2f4d3baf84c6ec7b8e0..66e4864c17af9d64299d093f336c65e66a7891a9 100644 (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