diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb index bfa152fd1..29314f4b1 100644 --- a/app/controllers/custom_fields_controller.rb +++ b/app/controllers/custom_fields_controller.rb @@ -25,7 +25,8 @@ class CustomFieldsController < ApplicationController end def list - @custom_field_pages, @custom_fields = paginate :custom_fields, :per_page => 15 + @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.type.to_s } + @tab = params[:tab] || 'IssueCustomField' render :action => "list", :layout => false if request.xhr? end @@ -44,7 +45,7 @@ class CustomFieldsController < ApplicationController end if request.post? and @custom_field.save flash[:notice] = l(:notice_successful_create) - redirect_to :action => 'list' + redirect_to :action => 'list', :tab => @custom_field.type end @trackers = Tracker.find(:all) end @@ -56,14 +57,14 @@ class CustomFieldsController < ApplicationController @custom_field.trackers = params[:tracker_ids] ? Tracker.find(params[:tracker_ids]) : [] end flash[:notice] = l(:notice_successful_update) - redirect_to :action => 'list' + redirect_to :action => 'list', :tab => @custom_field.type end @trackers = Tracker.find(:all) end def destroy - CustomField.find(params[:id]).destroy - redirect_to :action => 'list' + @custom_field = CustomField.find(params[:id]).destroy + redirect_to :action => 'list', :tab => @custom_field.type rescue flash[:notice] = "Unable to delete custom field" redirect_to :action => 'list' diff --git a/app/views/custom_fields/list.rhtml b/app/views/custom_fields/list.rhtml index 982e66aab..76637c8d5 100644 --- a/app/views/custom_fields/list.rhtml +++ b/app/views/custom_fields/list.rhtml @@ -1,38 +1,46 @@
<%=l(:field_name)%> | -<%=l(:field_type)%> | +<%=l(:field_name)%> | <%=l(:field_field_format)%> | -<%=l(:field_is_required)%> | +<%=l(:field_is_required)%> | + <% if type == 'IssueCustomField' %><%=l(:field_is_for_all)%> | -<%=l(:label_used_by)%> | -+ | <%=l(:label_used_by)%> | + <% end %> +|
---|---|---|---|---|---|---|---|---|---|---|
<%= link_to custom_field.name, :action => 'edit', :id => custom_field %> | -<%= l(custom_field.type_name) %> | +<%= link_to custom_field.name, :action => 'edit', :id => custom_field %> | <%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %> | -<%= image_tag 'true.png' if custom_field.is_required? %> | +<%= image_tag 'true.png' if custom_field.is_required? %> | + <% if type == 'IssueCustomField' %><%= image_tag 'true.png' if custom_field.is_for_all? %> | <%= 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? %> | + <% end %><%= button_to l(:button_delete), { :action => 'destroy', :id => custom_field }, :confirm => l(:text_are_you_sure), :class => "button-small" %> |