end
def list
- @custom_field_pages, @custom_fields = paginate :custom_fields, :per_page => 15\r
+ @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.type.to_s }\r
+ @tab = params[:tab] || 'IssueCustomField'\r
render :action => "list", :layout => false if request.xhr?
end
\r
end \r
if request.post? and @custom_field.save\r
flash[:notice] = l(:notice_successful_create)\r
- redirect_to :action => 'list'\r
+ redirect_to :action => 'list', :tab => @custom_field.type\r
end\r
@trackers = Tracker.find(:all)\r
end\r
@custom_field.trackers = params[:tracker_ids] ? Tracker.find(params[:tracker_ids]) : []\r
end\r
flash[:notice] = l(:notice_successful_update)\r
- redirect_to :action => 'list'\r
+ redirect_to :action => 'list', :tab => @custom_field.type\r
end\r
@trackers = Tracker.find(:all)\r
end\r
def destroy
- CustomField.find(params[:id]).destroy
- redirect_to :action => 'list'\r
+ @custom_field = CustomField.find(params[:id]).destroy\r
+ redirect_to :action => 'list', :tab => @custom_field.type\r
rescue\r
flash[:notice] = "Unable to delete custom field"\r
redirect_to :action => 'list'
<h2><%=l(:label_custom_field_plural)%></h2>
-\r
+
+<div class="tabs">
+<ul>
+<li><%= link_to l(:label_issue_plural), {}, :id=> "tab-IssueCustomField", :onclick => "showTab('IssueCustomField'); this.blur(); return false;" %></li>
+<li><%= link_to l(:label_project_plural), {}, :id=> "tab-ProjectCustomField", :onclick => "showTab('ProjectCustomField'); this.blur(); return false;" %></li>
+<li><%= link_to l(:label_user_plural), {}, :id=> "tab-UserCustomField", :onclick => "showTab('UserCustomField'); this.blur(); return false;" %></li>
+</ul>
+</div>\r
+
+<% %w(IssueCustomField ProjectCustomField UserCustomField).each do |type| %>
+<div id="tab-content-<%= type %>" class="tab-content">
<table class="list"> \r
<thead><tr>
- <th><%=l(:field_name)%></th>
- <th><%=l(:field_type)%></th>\r
+ <th width="30%"><%=l(:field_name)%></th>\r
<th><%=l(:field_field_format)%></th>\r
- <th><%=l(:field_is_required)%></th>\r
+ <th><%=l(:field_is_required)%></th>
+ <% if type == 'IssueCustomField' %>\r
<th><%=l(:field_is_for_all)%></th>\r
- <th><%=l(:label_used_by)%></th>\r
- <th></th>\r
+ <th><%=l(:label_used_by)%></th>
+ <% end %>\r
+ <th width="10%"></th>\r
</tr></thead>
<tbody>
-<% for custom_field in @custom_fields %>
+<% for custom_field in (@custom_fields_by_type[type] || []) %>
<tr class="<%= cycle("odd", "even") %>">\r
- <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td>\r
- <td align="center"><%= l(custom_field.type_name) %></td>
+ <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>\r
- <td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>\r
+ <td align="center"><%= image_tag 'true.png' if custom_field.is_required? %></td>
+ <% if type == 'IssueCustomField' %>\r
<td align="center"><%= image_tag 'true.png' if custom_field.is_for_all? %></td>\r
<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">
<%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %>
</td>
</tr>
-<% end %>
+<% end; reset_cycle %>
</tbody>
-</table>\r
-
-<%= pagination_links_full @custom_field_pages %>
-
+</table>
<br />
-<%=l(:label_custom_field_new)%>:
-<ul>
-<li><%= link_to l(:label_issue_plural), :action => 'new', :type => 'IssueCustomField' %></li>
-<li><%= link_to l(:label_project_plural), :action => 'new', :type => 'ProjectCustomField' %></li>
-<li><%= link_to l(:label_user_plural), :action => 'new', :type => 'UserCustomField' %></li>
-</ul>
+<%= link_to l(:label_custom_field_new), {:action => 'new', :type => type}, :class => 'icon icon-add' %>
+</div>
+<% end %>
+
+<%= javascript_tag "showTab('#{@tab}');" %>
\ No newline at end of file