]> source.dussan.org Git - redmine.git/commitdiff
CustomFieldsController#list moved to #index.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 17 Jan 2009 08:46:23 +0000 (08:46 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 17 Jan 2009 08:46:23 +0000 (08:46 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2274 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/custom_fields_controller.rb
app/views/custom_fields/index.rhtml [new file with mode: 0644]
app/views/custom_fields/list.rhtml [deleted file]
test/functional/custom_fields_controller_test.rb

index c9f798f5faaea4af0af5218355840a878af80ec1..5a79e4b7b5de31e2b8523dee71f05c23ae8ed252 100644 (file)
@@ -1,5 +1,5 @@
-# redMine - project management software
-# Copyright (C) 2006  Jean-Philippe Lang
+# Redmine - project management software
+# Copyright (C) 2006-2009  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -19,14 +19,8 @@ class CustomFieldsController < ApplicationController
   before_filter :require_admin
 
   def index
-    list
-    render :action => 'list' unless request.xhr?
-  end
-
-  def list
     @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name }
     @tab = params[:tab] || 'IssueCustomField'
-    render :action => "list", :layout => false if request.xhr?
   end
   
   def new
@@ -36,11 +30,11 @@ class CustomFieldsController < ApplicationController
       end
     rescue
     end
-    redirect_to(:action => 'list') and return unless @custom_field.is_a?(CustomField)
+    redirect_to(:action => 'index') and return unless @custom_field.is_a?(CustomField)
     
     if request.post? and @custom_field.save
       flash[:notice] = l(:notice_successful_create)
-      redirect_to :action => 'list', :tab => @custom_field.class.name
+      redirect_to :action => 'index', :tab => @custom_field.class.name
     end
     @trackers = Tracker.find(:all, :order => 'position')
   end
@@ -49,7 +43,7 @@ class CustomFieldsController < ApplicationController
     @custom_field = CustomField.find(params[:id])
     if request.post? and @custom_field.update_attributes(params[:custom_field])
       flash[:notice] = l(:notice_successful_update)
-      redirect_to :action => 'list', :tab => @custom_field.class.name
+      redirect_to :action => 'index', :tab => @custom_field.class.name
     end
     @trackers = Tracker.find(:all, :order => 'position')
   end
@@ -66,14 +60,14 @@ class CustomFieldsController < ApplicationController
     when 'lowest'
       @custom_field.move_to_bottom
     end if params[:position]
-    redirect_to :action => 'list', :tab => @custom_field.class.name
+    redirect_to :action => 'index', :tab => @custom_field.class.name
   end
   
   def destroy
     @custom_field = CustomField.find(params[:id]).destroy
-    redirect_to :action => 'list', :tab => @custom_field.class.name
+    redirect_to :action => 'index', :tab => @custom_field.class.name
   rescue
     flash[:error] = "Unable to delete custom field"
-    redirect_to :action => 'list'
+    redirect_to :action => 'index'
   end
 end
diff --git a/app/views/custom_fields/index.rhtml b/app/views/custom_fields/index.rhtml
new file mode 100644 (file)
index 0000000..43ddd99
--- /dev/null
@@ -0,0 +1,58 @@
+<h2><%=l(:label_custom_field_plural)%></h2>
+
+<% selected_tab = params[:tab] ? params[:tab].to_s : custom_fields_tabs.first[:name] %>
+
+<div class="tabs">
+<ul>
+<% custom_fields_tabs.each do |tab| -%>
+    <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
+                                    :id => "tab-#{tab[:name]}",
+                                    :class => (tab[:name] != selected_tab ? nil : 'selected'),
+                                    :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
+<% end -%>
+</ul>
+</div>
+
+<% custom_fields_tabs.each do |tab| %>
+<div id="tab-content-<%= tab[:name] %>" class="tab-content" style="<%= tab[:name] != selected_tab ? 'display:none' : nil %>">
+<table class="list">           
+  <thead><tr>  
+       <th width="30%"><%=l(:field_name)%></th>
+       <th><%=l(:field_field_format)%></th>
+       <th><%=l(:field_is_required)%></th>
+       <% if tab[:name] == 'IssueCustomField' %>
+       <th><%=l(:field_is_for_all)%></th>
+       <th><%=l(:label_used_by)%></th>
+       <% end %>
+       <th><%=l(:button_sort)%></th>
+       <th width="10%"></th>
+  </tr></thead>
+  <tbody>
+<% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
+  <tr class="<%= cycle("odd", "even") %>">
+       <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
+       <td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td>
+       <td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>
+       <% if tab[:name] == 'IssueCustomField' %>
+       <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
+       <td align="center"><%= custom_field.projects.count.to_s + ' ' + lwr(:label_project, 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">
+          <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
+    </td>
+  </tr>
+<% end; reset_cycle %>
+  </tbody>
+</table>
+
+<p><%= link_to l(:label_custom_field_new), {:action => 'new', :type => tab[:name]}, :class => 'icon icon-add' %></p>
+</div>
+<% end %>
+
+<% html_title(l(:label_custom_field_plural)) -%>
diff --git a/app/views/custom_fields/list.rhtml b/app/views/custom_fields/list.rhtml
deleted file mode 100644 (file)
index 43ddd99..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<h2><%=l(:label_custom_field_plural)%></h2>
-
-<% selected_tab = params[:tab] ? params[:tab].to_s : custom_fields_tabs.first[:name] %>
-
-<div class="tabs">
-<ul>
-<% custom_fields_tabs.each do |tab| -%>
-    <li><%= link_to l(tab[:label]), { :tab => tab[:name] },
-                                    :id => "tab-#{tab[:name]}",
-                                    :class => (tab[:name] != selected_tab ? nil : 'selected'),
-                                    :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
-<% end -%>
-</ul>
-</div>
-
-<% custom_fields_tabs.each do |tab| %>
-<div id="tab-content-<%= tab[:name] %>" class="tab-content" style="<%= tab[:name] != selected_tab ? 'display:none' : nil %>">
-<table class="list">           
-  <thead><tr>  
-       <th width="30%"><%=l(:field_name)%></th>
-       <th><%=l(:field_field_format)%></th>
-       <th><%=l(:field_is_required)%></th>
-       <% if tab[:name] == 'IssueCustomField' %>
-       <th><%=l(:field_is_for_all)%></th>
-       <th><%=l(:label_used_by)%></th>
-       <% end %>
-       <th><%=l(:button_sort)%></th>
-       <th width="10%"></th>
-  </tr></thead>
-  <tbody>
-<% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%>
-  <tr class="<%= cycle("odd", "even") %>">
-       <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>
-       <td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td>
-       <td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>
-       <% if tab[:name] == 'IssueCustomField' %>
-       <td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>
-       <td align="center"><%= custom_field.projects.count.to_s + ' ' + lwr(:label_project, 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">
-          <%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
-    </td>
-  </tr>
-<% end; reset_cycle %>
-  </tbody>
-</table>
-
-<p><%= link_to l(:label_custom_field_new), {:action => 'new', :type => tab[:name]}, :class => 'icon icon-add' %></p>
-</div>
-<% end %>
-
-<% html_title(l(:label_custom_field_plural)) -%>
index c37368da27ba1c65565b1a010622d541dcc62de7..42dedb3c1ee0becdf8d58b016697640b32cf5c4b 100644 (file)
@@ -47,7 +47,7 @@ class CustomFieldsControllerTest < Test::Unit::TestCase
                                    :field_format => "list",\r
                                    :tracker_ids => ["1", ""]}\r
     end        \r
-    assert_redirected_to '/custom_fields/list'\r
+    assert_redirected_to '/custom_fields'\r
     field = IssueCustomField.find_by_name('test_post_new_list')\r
     assert_not_nil field\r
     assert_equal ["0.1", "0.2"], field.possible_values\r
@@ -56,6 +56,6 @@ class CustomFieldsControllerTest < Test::Unit::TestCase
   \r
   def test_invalid_custom_field_class_should_redirect_to_list\r
     get :new, :type => 'UnknownCustomField'\r
-    assert_redirected_to '/custom_fields/list'\r
+    assert_redirected_to '/custom_fields'\r
   end\r
 end\r