##// END OF EJS Templates
Reorder links refactoring (follows r2526)....
Jean-Philippe Lang -
r2478:47f5713b1e1c
parent child
Show More
@@ -62,12 +62,6 class BoardsController < ApplicationController
62 62
63 63 def edit
64 64 if request.post? && @board.update_attributes(params[:board])
65 case params[:position]
66 when 'highest'; @board.move_to_top
67 when 'higher'; @board.move_higher
68 when 'lower'; @board.move_lower
69 when 'lowest'; @board.move_to_bottom
70 end if params[:position]
71 65 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
72 66 end
73 67 end
@@ -47,21 +47,6 class CustomFieldsController < ApplicationController
47 47 end
48 48 @trackers = Tracker.find(:all, :order => 'position')
49 49 end
50
51 def move
52 @custom_field = CustomField.find(params[:id])
53 case params[:position]
54 when 'highest'
55 @custom_field.move_to_top
56 when 'higher'
57 @custom_field.move_higher
58 when 'lower'
59 @custom_field.move_lower
60 when 'lowest'
61 @custom_field.move_to_bottom
62 end if params[:position]
63 redirect_to :action => 'index', :tab => @custom_field.class.name
64 end
65 50
66 51 def destroy
67 52 @custom_field = CustomField.find(params[:id]).destroy
@@ -57,21 +57,6 class EnumerationsController < ApplicationController
57 57 render :action => 'edit'
58 58 end
59 59 end
60
61 def move
62 @enumeration = Enumeration.find(params[:id])
63 case params[:position]
64 when 'highest'
65 @enumeration.move_to_top
66 when 'higher'
67 @enumeration.move_higher
68 when 'lower'
69 @enumeration.move_lower
70 when 'lowest'
71 @enumeration.move_to_bottom
72 end if params[:position]
73 redirect_to :action => 'index'
74 end
75 60
76 61 def destroy
77 62 @enumeration = Enumeration.find(params[:id])
@@ -58,21 +58,6 class IssueStatusesController < ApplicationController
58 58 render :action => 'edit'
59 59 end
60 60 end
61
62 def move
63 @issue_status = IssueStatus.find(params[:id])
64 case params[:position]
65 when 'highest'
66 @issue_status.move_to_top
67 when 'higher'
68 @issue_status.move_higher
69 when 'lower'
70 @issue_status.move_lower
71 when 'lowest'
72 @issue_status.move_to_bottom
73 end if params[:position]
74 redirect_to :action => 'list'
75 end
76 61
77 62 def destroy
78 63 IssueStatus.find(params[:id]).destroy
@@ -64,21 +64,6 class RolesController < ApplicationController
64 64 redirect_to :action => 'index'
65 65 end
66 66
67 def move
68 @role = Role.find(params[:id])
69 case params[:position]
70 when 'highest'
71 @role.move_to_top
72 when 'higher'
73 @role.move_higher
74 when 'lower'
75 @role.move_lower
76 when 'lowest'
77 @role.move_to_bottom
78 end if params[:position]
79 redirect_to :action => 'list'
80 end
81
82 67 def report
83 68 @roles = Role.find(:all, :order => 'builtin, position')
84 69 @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
@@ -37,12 +37,7
37 37 <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
38 38 <td align="center"><%= l(:label_x_projects, :count => custom_field.projects.count) if custom_field.is_a? IssueCustomField and !custom_field.is_for_all? %></td>
39 39 <% end %>
40 <td align="center" style="width:15%;">
41 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => custom_field, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
42 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => custom_field, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
43 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => custom_field, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
44 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => custom_field, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
45 </td>
40 <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
46 41 <td align="center">
47 42 <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
48 43 </td>
@@ -10,12 +10,7
10 10 <tr class="<%= cycle('odd', 'even') %>">
11 11 <td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td>
12 12 <td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td>
13 <td style="width:15%;">
14 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => enumeration, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
15 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => enumeration, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
16 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => enumeration, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
17 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => enumeration, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
18 </td>
13 <td style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}) %></td>
19 14 <td align="center" style="width:10%;">
20 15 <%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration }, :method => :post, :confirm => l(:text_are_you_sure), :class => "icon icon-del" %>
21 16 </td>
@@ -18,12 +18,7
18 18 <td><%= link_to status.name, :action => 'edit', :id => status %></td>
19 19 <td align="center"><%= image_tag 'true.png' if status.is_default? %></td>
20 20 <td align="center"><%= image_tag 'true.png' if status.is_closed? %></td>
21 <td align="center" style="width:15%;">
22 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => status, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
23 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => status, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
24 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => status, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
25 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => status, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
26 </td>
21 <td align="center" style="width:15%;"><%= reorder_links('issue_status', {:action => 'update', :id => status}) %></td>
27 22 <td align="center" style="width:10%;">
28 23 <%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
29 24 </td>
@@ -9,10 +9,7
9 9 <td><%=h board.description %></td>
10 10 <td align="center">
11 11 <% if authorize_for("boards", "edit") %>
12 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
13 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
14 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
15 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
12 <%= reorder_links('board', {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}) %>
16 13 <% end %>
17 14 </td>
18 15 <td align="center"><%= link_to_if_authorized l(:button_edit), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}, :class => 'icon icon-edit' %></td>
@@ -16,10 +16,7
16 16 <td><%= content_tag(role.builtin? ? 'em' : 'span', link_to(role.name, :action => 'edit', :id => role)) %></td>
17 17 <td align="center" style="width:15%;">
18 18 <% unless role.builtin? %>
19 <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => role, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
20 <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => role, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
21 <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => role, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
22 <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => role, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
19 <%= reorder_links('role', {:action => 'edit', :id => role}) %>
23 20 <% end %>
24 21 </td>
25 22 <td align="center" style="width:10%;">
@@ -153,27 +153,27 class RolesControllerTest < Test::Unit::TestCase
153 153 end
154 154
155 155 def test_move_highest
156 post :move, :id => 3, :position => 'highest'
156 post :edit, :id => 3, :role => {:move_to => 'highest'}
157 157 assert_redirected_to 'roles/list'
158 158 assert_equal 1, Role.find(3).position
159 159 end
160 160
161 161 def test_move_higher
162 162 position = Role.find(3).position
163 post :move, :id => 3, :position => 'higher'
163 post :edit, :id => 3, :role => {:move_to => 'higher'}
164 164 assert_redirected_to 'roles/list'
165 165 assert_equal position - 1, Role.find(3).position
166 166 end
167 167
168 168 def test_move_lower
169 169 position = Role.find(2).position
170 post :move, :id => 2, :position => 'lower'
170 post :edit, :id => 2, :role => {:move_to => 'lower'}
171 171 assert_redirected_to 'roles/list'
172 172 assert_equal position + 1, Role.find(2).position
173 173 end
174 174
175 175 def test_move_lowest
176 post :move, :id => 2, :position => 'lowest'
176 post :edit, :id => 2, :role => {:move_to => 'lowest'}
177 177 assert_redirected_to 'roles/list'
178 178 assert_equal Role.count, Role.find(2).position
179 179 end
General Comments 0
You need to be logged in to leave comments. Login now