##// END OF EJS Templates
Start removing the RJS stuff....
Jean-Philippe Lang -
r9860:035805fbd042
parent child
Show More
@@ -0,0 +1,3
1 hideModal();
2 <% 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]') %>
3 Element.replace('issue_category_id', '<%= escape_javascript(select) %>');
@@ -0,0 +1,3
1 Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'issue_categories/new_modal') %>');
2 showModal('ajax-modal', '600px');
3 Form.Element.focus('issue_category_name');
@@ -0,0 +1,3
1 hideModal();
2 <% 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]') %>
3 Element.replace('issue_fixed_version_id', '<%= escape_javascript(select) %>');
@@ -0,0 +1,3
1 Element.update('ajax-modal', '<%= escape_javascript(render :partial => 'versions/new_modal') %>');
2 showModal('ajax-modal', '600px');
3 Form.Element.focus('version_name');
@@ -44,13 +44,7 class IssueCategoriesController < ApplicationController
44
44
45 respond_to do |format|
45 respond_to do |format|
46 format.html
46 format.html
47 format.js do
47 format.js
48 render :update do |page|
49 page.replace_html 'ajax-modal', :partial => 'issue_categories/new_modal'
50 page << "showModal('ajax-modal', '600px');"
51 page << "Form.Element.focus('issue_category_name');"
52 end
53 end
54 end
48 end
55 end
49 end
56
50
@@ -63,25 +57,13 class IssueCategoriesController < ApplicationController
63 flash[:notice] = l(:notice_successful_create)
57 flash[:notice] = l(:notice_successful_create)
64 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
58 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
65 end
59 end
66 format.js do
60 format.js
67 render(:update) {|page|
68 page << 'hideModal();'
69 # IE doesn't support the replace_html rjs method for select box options
70 page.replace "issue_category_id",
71 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]')
72 }
73 end
74 format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
61 format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
75 end
62 end
76 else
63 else
77 respond_to do |format|
64 respond_to do |format|
78 format.html { render :action => 'new'}
65 format.html { render :action => 'new'}
79 format.js do
66 format.js { render :action => 'new'}
80 render :update do |page|
81 page.replace_html 'ajax-modal', :partial => 'issue_categories/new_modal'
82 page << "Form.Element.focus('version_name');"
83 end
84 end
85 format.api { render_validation_errors(@category) }
67 format.api { render_validation_errors(@category) }
86 end
68 end
87 end
69 end
@@ -78,13 +78,7 class VersionsController < ApplicationController
78
78
79 respond_to do |format|
79 respond_to do |format|
80 format.html
80 format.html
81 format.js do
81 format.js
82 render :update do |page|
83 page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
84 page << "showModal('ajax-modal', '600px');"
85 page << "Form.Element.focus('version_name');"
86 end
87 end
88 end
82 end
89 end
83 end
90
84
@@ -103,14 +97,7 class VersionsController < ApplicationController
103 flash[:notice] = l(:notice_successful_create)
97 flash[:notice] = l(:notice_successful_create)
104 redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
98 redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
105 end
99 end
106 format.js do
100 format.js
107 render(:update) {|page|
108 page << 'hideModal();'
109 # IE doesn't support the replace_html rjs method for select box options
110 page.replace "issue_fixed_version_id",
111 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]')
112 }
113 end
114 format.api do
101 format.api do
115 render :action => 'show', :status => :created, :location => version_url(@version)
102 render :action => 'show', :status => :created, :location => version_url(@version)
116 end
103 end
@@ -118,12 +105,7 class VersionsController < ApplicationController
118 else
105 else
119 respond_to do |format|
106 respond_to do |format|
120 format.html { render :action => 'new' }
107 format.html { render :action => 'new' }
121 format.js do
108 format.js { render :action => 'new' }
122 render :update do |page|
123 page.replace_html 'ajax-modal', :partial => 'versions/new_modal'
124 page << "Form.Element.focus('version_name');"
125 end
126 end
127 format.api { render_validation_errors(@version) }
109 format.api { render_validation_errors(@version) }
128 end
110 end
129 end
111 end
@@ -40,6 +40,15 class IssueCategoriesControllerTest < ActionController::TestCase
40 assert_select 'input[name=?]', 'issue_category[name]'
40 assert_select 'input[name=?]', 'issue_category[name]'
41 end
41 end
42
42
43 def test_new_from_issue_form
44 @request.session[:user_id] = 2 # manager
45 xhr :get, :new, :project_id => '1'
46
47 assert_response :success
48 assert_template 'new'
49 assert_equal 'text/javascript', response.content_type
50 end
51
43 def test_create
52 def test_create
44 @request.session[:user_id] = 2 # manager
53 @request.session[:user_id] = 2 # manager
45 assert_difference 'IssueCategory.count' do
54 assert_difference 'IssueCategory.count' do
@@ -67,9 +76,8 class IssueCategoriesControllerTest < ActionController::TestCase
67 assert_equal 'New category', category.name
76 assert_equal 'New category', category.name
68
77
69 assert_response :success
78 assert_response :success
70 assert_select_rjs :replace, 'issue_category_id' do
79 assert_template 'create'
71 assert_select "option[value=#{category.id}][selected=selected]"
80 assert_equal 'text/javascript', response.content_type
72 end
73 end
81 end
74
82
75 def test_create_from_issue_form_with_failure
83 def test_create_from_issue_form_with_failure
@@ -79,9 +87,8 class IssueCategoriesControllerTest < ActionController::TestCase
79 end
87 end
80
88
81 assert_response :success
89 assert_response :success
82 assert_select_rjs :replace_html, "ajax-modal" do
90 assert_template 'new'
83 assert_select "div#errorExplanation"
91 assert_equal 'text/javascript', response.content_type
84 end
85 end
92 end
86
93
87 def test_edit
94 def test_edit
@@ -100,10 +100,8 class VersionsControllerTest < ActionController::TestCase
100 @request.session[:user_id] = 2
100 @request.session[:user_id] = 2
101 xhr :get, :new, :project_id => '1'
101 xhr :get, :new, :project_id => '1'
102 assert_response :success
102 assert_response :success
103 assert_select_rjs :replace_html, "ajax-modal" do
103 assert_template 'new'
104 assert_select "form[action=/projects/ecookbook/versions]"
104 assert_equal 'text/javascript', response.content_type
105 assert_select "input#version_name"
106 end
107 end
105 end
108
106
109 def test_create
107 def test_create
@@ -127,9 +125,8 class VersionsControllerTest < ActionController::TestCase
127 assert_equal 1, version.project_id
125 assert_equal 1, version.project_id
128
126
129 assert_response :success
127 assert_response :success
130 assert_select_rjs :replace, 'issue_fixed_version_id' do
128 assert_template 'create'
131 assert_select "option[value=#{version.id}][selected=selected]"
129 assert_equal 'text/javascript', response.content_type
132 end
133 end
130 end
134
131
135 def test_create_from_issue_form_with_failure
132 def test_create_from_issue_form_with_failure
@@ -138,9 +135,8 class VersionsControllerTest < ActionController::TestCase
138 xhr :post, :create, :project_id => '1', :version => {:name => ''}
135 xhr :post, :create, :project_id => '1', :version => {:name => ''}
139 end
136 end
140 assert_response :success
137 assert_response :success
141 assert_select_rjs :replace_html, "ajax-modal" do
138 assert_template 'new'
142 assert_select "div#errorExplanation"
139 assert_equal 'text/javascript', response.content_type
143 end
144 end
140 end
145
141
146 def test_get_edit
142 def test_get_edit
General Comments 0
You need to be logged in to leave comments. Login now