##// 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 def edit
63 def edit
64 if request.post? && @board.update_attributes(params[:board])
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 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
65 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
72 end
66 end
73 end
67 end
@@ -47,21 +47,6 class CustomFieldsController < ApplicationController
47 end
47 end
48 @trackers = Tracker.find(:all, :order => 'position')
48 @trackers = Tracker.find(:all, :order => 'position')
49 end
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 def destroy
51 def destroy
67 @custom_field = CustomField.find(params[:id]).destroy
52 @custom_field = CustomField.find(params[:id]).destroy
@@ -57,21 +57,6 class EnumerationsController < ApplicationController
57 render :action => 'edit'
57 render :action => 'edit'
58 end
58 end
59 end
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 def destroy
61 def destroy
77 @enumeration = Enumeration.find(params[:id])
62 @enumeration = Enumeration.find(params[:id])
@@ -58,21 +58,6 class IssueStatusesController < ApplicationController
58 render :action => 'edit'
58 render :action => 'edit'
59 end
59 end
60 end
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 def destroy
62 def destroy
78 IssueStatus.find(params[:id]).destroy
63 IssueStatus.find(params[:id]).destroy
@@ -64,21 +64,6 class RolesController < ApplicationController
64 redirect_to :action => 'index'
64 redirect_to :action => 'index'
65 end
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 def report
67 def report
83 @roles = Role.find(:all, :order => 'builtin, position')
68 @roles = Role.find(:all, :order => 'builtin, position')
84 @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
69 @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
@@ -37,12 +37,7
37 <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
37 <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
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>
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 <% end %>
39 <% end %>
40 <td align="center" style="width:15%;">
40 <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
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>
46 <td align="center">
41 <td align="center">
47 <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
42 <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
48 </td>
43 </td>
@@ -10,12 +10,7
10 <tr class="<%= cycle('odd', 'even') %>">
10 <tr class="<%= cycle('odd', 'even') %>">
11 <td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td>
11 <td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td>
12 <td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td>
12 <td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td>
13 <td style="width:15%;">
13 <td style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}) %></td>
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>
19 <td align="center" style="width:10%;">
14 <td align="center" style="width:10%;">
20 <%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration }, :method => :post, :confirm => l(:text_are_you_sure), :class => "icon icon-del" %>
15 <%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration }, :method => :post, :confirm => l(:text_are_you_sure), :class => "icon icon-del" %>
21 </td>
16 </td>
@@ -18,12 +18,7
18 <td><%= link_to status.name, :action => 'edit', :id => status %></td>
18 <td><%= link_to status.name, :action => 'edit', :id => status %></td>
19 <td align="center"><%= image_tag 'true.png' if status.is_default? %></td>
19 <td align="center"><%= image_tag 'true.png' if status.is_default? %></td>
20 <td align="center"><%= image_tag 'true.png' if status.is_closed? %></td>
20 <td align="center"><%= image_tag 'true.png' if status.is_closed? %></td>
21 <td align="center" style="width:15%;">
21 <td align="center" style="width:15%;"><%= reorder_links('issue_status', {:action => 'update', :id => status}) %></td>
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>
27 <td align="center" style="width:10%;">
22 <td align="center" style="width:10%;">
28 <%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
23 <%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
29 </td>
24 </td>
@@ -9,10 +9,7
9 <td><%=h board.description %></td>
9 <td><%=h board.description %></td>
10 <td align="center">
10 <td align="center">
11 <% if authorize_for("boards", "edit") %>
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) %>
12 <%= reorder_links('board', {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}) %>
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) %>
16 <% end %>
13 <% end %>
17 </td>
14 </td>
18 <td align="center"><%= link_to_if_authorized l(:button_edit), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}, :class => 'icon icon-edit' %></td>
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 <td><%= content_tag(role.builtin? ? 'em' : 'span', link_to(role.name, :action => 'edit', :id => role)) %></td>
16 <td><%= content_tag(role.builtin? ? 'em' : 'span', link_to(role.name, :action => 'edit', :id => role)) %></td>
17 <td align="center" style="width:15%;">
17 <td align="center" style="width:15%;">
18 <% unless role.builtin? %>
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) %>
19 <%= reorder_links('role', {:action => 'edit', :id => role}) %>
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) %>
23 <% end %>
20 <% end %>
24 </td>
21 </td>
25 <td align="center" style="width:10%;">
22 <td align="center" style="width:10%;">
@@ -153,27 +153,27 class RolesControllerTest < Test::Unit::TestCase
153 end
153 end
154
154
155 def test_move_highest
155 def test_move_highest
156 post :move, :id => 3, :position => 'highest'
156 post :edit, :id => 3, :role => {:move_to => 'highest'}
157 assert_redirected_to 'roles/list'
157 assert_redirected_to 'roles/list'
158 assert_equal 1, Role.find(3).position
158 assert_equal 1, Role.find(3).position
159 end
159 end
160
160
161 def test_move_higher
161 def test_move_higher
162 position = Role.find(3).position
162 position = Role.find(3).position
163 post :move, :id => 3, :position => 'higher'
163 post :edit, :id => 3, :role => {:move_to => 'higher'}
164 assert_redirected_to 'roles/list'
164 assert_redirected_to 'roles/list'
165 assert_equal position - 1, Role.find(3).position
165 assert_equal position - 1, Role.find(3).position
166 end
166 end
167
167
168 def test_move_lower
168 def test_move_lower
169 position = Role.find(2).position
169 position = Role.find(2).position
170 post :move, :id => 2, :position => 'lower'
170 post :edit, :id => 2, :role => {:move_to => 'lower'}
171 assert_redirected_to 'roles/list'
171 assert_redirected_to 'roles/list'
172 assert_equal position + 1, Role.find(2).position
172 assert_equal position + 1, Role.find(2).position
173 end
173 end
174
174
175 def test_move_lowest
175 def test_move_lowest
176 post :move, :id => 2, :position => 'lowest'
176 post :edit, :id => 2, :role => {:move_to => 'lowest'}
177 assert_redirected_to 'roles/list'
177 assert_redirected_to 'roles/list'
178 assert_equal Role.count, Role.find(2).position
178 assert_equal Role.count, Role.find(2).position
179 end
179 end
General Comments 0
You need to be logged in to leave comments. Login now