Feature #25064 Custom Fields table: Remove sorting for work package CFs and link to types (#5503)

* CF table: Remove sorting for work package custom fields and add types that use that cf

* Optimize query

[ci skip]
This commit is contained in:
Wieland Lindenthal
2017-05-16 16:42:10 +02:00
committed by Oliver Günther
parent 3157bbb7a0
commit fd1f14df73
4 changed files with 35 additions and 12 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ class CustomFieldsController < ApplicationController
before_action :get_custom_field_params, only: %i(create update)
def index
@custom_fields_by_type = CustomField.all.group_by { |f| f.class.name }
@custom_fields_by_type = CustomField.all.includes(:types).group_by { |f| f.class.name }
@tab = params[:tab] || 'WorkPackageCustomField'
end
+5 -1
View File
@@ -182,7 +182,11 @@ class CustomField < ActiveRecord::Base
end
def <=>(field)
position <=> field.position
if type == 'WorkPackageCustomField'
name.downcase <=> field.name.downcase
else
position <=> field.position
end
end
def self.customized_class
+27 -10
View File
@@ -85,21 +85,32 @@ See doc/COPYRIGHT.rdoc for more details.
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%=l(:label_used_by)%>
<%= t(:label_used_in_projects) %>
</span>
</div>
</div>
</th>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%= t('custom_fields.contained_in_type') %>
</span>
</div>
</div>
</th>
<% end %>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%=l(:button_sort)%>
</span>
<% unless tab[:name] == 'WorkPackageCustomField' %>
<th>
<div class="generic-table--sort-header-outer">
<div class="generic-table--sort-header">
<span>
<%=l(:button_sort)%>
</span>
</div>
</div>
</div>
</th>
</th>
<% end %>
<th><div class="generic-table--empty-header"></div></th>
</tr>
</thead>
@@ -112,8 +123,14 @@ See doc/COPYRIGHT.rdoc for more details.
<% if tab[:name] == 'WorkPackageCustomField' %>
<td><%= checked_image custom_field.is_for_all? %></td>
<td><%= l(:label_x_projects, count: custom_field.projects.count) if custom_field.is_a? WorkPackageCustomField and !custom_field.is_for_all? %></td>
<td>
<% type_links = custom_field.types.map { |t| link_to(t.name, edit_type_tab_path(id: t.id, tab: 'form_configuration')) } %>
<%= safe_join type_links, ', '.html_safe %>
</td>
<% end %>
<% unless tab[:name] == 'WorkPackageCustomField' %>
<td><%= reorder_links('custom_field', { action: 'update', id: custom_field, back_url: custom_fields_path }, method: :put) %></td>
<% end %>
<td><%= reorder_links('custom_field', { action: 'update', id: custom_field, back_url: custom_fields_path }, method: :put) %></td>
<td class="buttons">
<%= delete_link custom_field_path(custom_field) %>
</td>
+2
View File
@@ -1381,6 +1381,8 @@ en:
label_updated_time_at: "%{author} %{age}"
label_updated_time_by: "Updated by %{author} %{age} ago"
label_used_by: "Used by"
label_used_by_types: "Used by types"
label_used_in_projects: "Used in projects"
label_user: "User"
label_user_activity: "%{value}'s activity"
label_user_anonymous: "Anonymous"