OSDN Git Service

Reorder links refactoring (follows r2526).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 1 Mar 2009 12:03:48 +0000 (12:03 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 1 Mar 2009 12:03:48 +0000 (12:03 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2546 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/boards_controller.rb
app/controllers/custom_fields_controller.rb
app/controllers/enumerations_controller.rb
app/controllers/issue_statuses_controller.rb
app/controllers/roles_controller.rb
app/views/custom_fields/index.rhtml
app/views/enumerations/list.rhtml
app/views/issue_statuses/list.rhtml
app/views/projects/settings/_boards.rhtml
app/views/roles/list.rhtml
test/functional/roles_controller_test.rb

index 55a9737..838e63a 100644 (file)
@@ -62,12 +62,6 @@ class BoardsController < ApplicationController
 
   def edit
     if request.post? && @board.update_attributes(params[:board])
-      case params[:position]
-      when 'highest'; @board.move_to_top
-      when 'higher'; @board.move_higher
-      when 'lower'; @board.move_lower
-      when 'lowest'; @board.move_to_bottom
-      end if params[:position]
       redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
     end
   end
index 5a79e4b..73ae809 100644 (file)
@@ -47,21 +47,6 @@ class CustomFieldsController < ApplicationController
     end
     @trackers = Tracker.find(:all, :order => 'position')
   end
-
-  def move
-    @custom_field = CustomField.find(params[:id])
-    case params[:position]
-    when 'highest'
-      @custom_field.move_to_top
-    when 'higher'
-      @custom_field.move_higher
-    when 'lower'
-      @custom_field.move_lower
-    when 'lowest'
-      @custom_field.move_to_bottom
-    end if params[:position]
-    redirect_to :action => 'index', :tab => @custom_field.class.name
-  end
   
   def destroy
     @custom_field = CustomField.find(params[:id]).destroy
index 6e136fb..ac55c42 100644 (file)
@@ -57,21 +57,6 @@ class EnumerationsController < ApplicationController
       render :action => 'edit'
     end
   end
-
-  def move
-    @enumeration = Enumeration.find(params[:id])
-    case params[:position]
-    when 'highest'
-      @enumeration.move_to_top
-    when 'higher'
-      @enumeration.move_higher
-    when 'lower'
-      @enumeration.move_lower
-    when 'lowest'
-      @enumeration.move_to_bottom
-    end if params[:position]
-    redirect_to :action => 'index'
-  end
   
   def destroy
     @enumeration = Enumeration.find(params[:id])
index 69d9db9..bee7f48 100644 (file)
@@ -58,21 +58,6 @@ class IssueStatusesController < ApplicationController
       render :action => 'edit'
     end
   end
-  
-  def move
-    @issue_status = IssueStatus.find(params[:id])
-    case params[:position]
-    when 'highest'
-      @issue_status.move_to_top
-    when 'higher'
-      @issue_status.move_higher
-    when 'lower'
-      @issue_status.move_lower
-    when 'lowest'
-      @issue_status.move_to_bottom
-    end if params[:position]
-    redirect_to :action => 'list'
-  end
 
   def destroy
     IssueStatus.find(params[:id]).destroy
index ab70ebf..6185d70 100644 (file)
@@ -64,21 +64,6 @@ class RolesController < ApplicationController
     redirect_to :action => 'index'
   end
   
-  def move
-    @role = Role.find(params[:id])
-    case params[:position]
-    when 'highest'
-      @role.move_to_top
-    when 'higher'
-      @role.move_higher
-    when 'lower'
-      @role.move_lower
-    when 'lowest'
-      @role.move_to_bottom
-    end if params[:position]
-    redirect_to :action => 'list'
-  end
-  
   def report    
     @roles = Role.find(:all, :order => 'builtin, position')
     @permissions = Redmine::AccessControl.permissions.select { |p| !p.public? }
index 70b7197..999648f 100644 (file)
        <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
        <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>
        <% end %>
-    <td align="center" style="width:15%;">
-        <%= 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) %>
-        <%= 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) %> -
-        <%= 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) %>
-        <%= 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) %>
-    </td>
+    <td align="center" style="width:15%;"><%= reorder_links('custom_field', {:action => 'edit', :id => custom_field}) %></td>
        <td align="center">
           <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
     </td>
index c4a9af2..485dec7 100644 (file)
 <tr class="<%= cycle('odd', 'even') %>">
     <td><%= link_to h(enumeration), :action => 'edit', :id => enumeration %></td>
     <td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td>
-    <td style="width:15%;">
-    <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => enumeration, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
-    <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => enumeration, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
-    <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => enumeration, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
-    <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => enumeration, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
-    </td>
+    <td style="width:15%;"><%= reorder_links('enumeration', {:action => 'update', :id => enumeration}) %></td>
     <td align="center" style="width:10%;">
     <%= link_to l(:button_delete), { :action => 'destroy', :id => enumeration }, :method => :post, :confirm => l(:text_are_you_sure), :class => "icon icon-del" %>
     </td>
index e359118..fd4e3e8 100644 (file)
   <td><%= link_to status.name, :action => 'edit', :id => status %></td>
   <td align="center"><%= image_tag 'true.png' if status.is_default? %></td>
   <td align="center"><%= image_tag 'true.png' if status.is_closed? %></td>
-  <td align="center" style="width:15%;">
-    <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => status, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
-    <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => status, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
-    <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => status, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
-    <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => status, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
-  </td>
+  <td align="center" style="width:15%;"><%= reorder_links('issue_status', {:action => 'update', :id => status}) %></td>
   <td align="center" style="width:10%;">
     <%= button_to l(:button_delete), { :action => 'destroy', :id => status }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
   </td>
index bf6da3a..e1b7ff3 100644 (file)
@@ -9,10 +9,7 @@
     <td><%=h board.description %></td>
     <td align="center">
     <% if authorize_for("boards", "edit") %>
-    <%= 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) %>
-    <%= 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) %> -
-    <%= 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) %>
-    <%= 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) %>
+                       <%= reorder_links('board', {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}) %>
     <% end %>
     </td>    
     <td align="center"><%= link_to_if_authorized l(:button_edit), {:controller => 'boards', :action => 'edit', :project_id => @project, :id => board}, :class => 'icon icon-edit' %></td>
index 93b8213..32ff716 100644 (file)
   <td><%= content_tag(role.builtin? ? 'em' : 'span', link_to(role.name, :action => 'edit', :id => role)) %></td>
   <td align="center" style="width:15%;">
   <% unless role.builtin? %>
-    <%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => role, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
-    <%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => role, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
-    <%= link_to image_tag('1downarrow.png', :alt => l(:label_sort_lower)), {:action => 'move', :id => role, :position => 'lower'}, :method => :post, :title => l(:label_sort_lower) %>
-    <%= link_to image_tag('2downarrow.png', :alt => l(:label_sort_lowest)), {:action => 'move', :id => role, :position => 'lowest'}, :method => :post, :title => l(:label_sort_lowest) %>
+    <%= reorder_links('role', {:action => 'edit', :id => role}) %>
   <% end %>
   </td>
   <td align="center" style="width:10%;">
index 188e79e..5c47be1 100644 (file)
@@ -153,27 +153,27 @@ class RolesControllerTest < Test::Unit::TestCase
   end
   
   def test_move_highest
-    post :move, :id => 3, :position => 'highest'
+    post :edit, :id => 3, :role => {:move_to => 'highest'}
     assert_redirected_to 'roles/list'
     assert_equal 1, Role.find(3).position
   end
 
   def test_move_higher
     position = Role.find(3).position
-    post :move, :id => 3, :position => 'higher'
+    post :edit, :id => 3, :role => {:move_to => 'higher'}
     assert_redirected_to 'roles/list'
     assert_equal position - 1, Role.find(3).position
   end
 
   def test_move_lower
     position = Role.find(2).position
-    post :move, :id => 2, :position => 'lower'
+    post :edit, :id => 2, :role => {:move_to => 'lower'}
     assert_redirected_to 'roles/list'
     assert_equal position + 1, Role.find(2).position
   end
 
   def test_move_lowest
-    post :move, :id => 2, :position => 'lowest'
+    post :edit, :id => 2, :role => {:move_to => 'lowest'}
     assert_redirected_to 'roles/list'
     assert_equal Role.count, Role.find(2).position
   end