-# 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
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
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
@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
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
--- /dev/null
+<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)) -%>
+++ /dev/null
-<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)) -%>
: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
\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