diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-10 13:03:52 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-01-10 13:03:52 +0000 |
commit | a18c719fcc9cf2bf44bed59944ae1ad349dce970 (patch) | |
tree | 3e9f836b1c3edda9f6decb095509e58e1e02c01f /app | |
parent | a77d884157439c226342e789f13bd6bfe8dd4227 (diff) | |
download | redmine-a18c719fcc9cf2bf44bed59944ae1ad349dce970.tar.gz redmine-a18c719fcc9cf2bf44bed59944ae1ad349dce970.zip |
Fixed: Custom field is rendered, even if its value is empty (for multiple) (#18654).
git-svn-id: http://svn.redmine.org/redmine/trunk@13864 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/custom_fields_helper.rb | 11 | ||||
-rw-r--r-- | app/views/projects/show.html.erb | 6 | ||||
-rw-r--r-- | app/views/versions/_overview.html.erb | 6 |
3 files changed, 15 insertions, 8 deletions
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 5153c1489..ca37a2bc0 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -117,6 +117,17 @@ module CustomFieldsHelper Redmine::FieldFormat.as_select(custom_field.class.customized_class.name) end + # Yields the given block for each custom field value of object that should be + # displayed, with the custom field and the formatted value as arguments + def render_custom_field_values(object, &block) + object.visible_custom_field_values.each do |custom_value| + formatted = show_value(custom_value) + if formatted.present? + yield custom_value.custom_field, formatted + end + end + end + # Renders the custom_values in api views def render_api_custom_values(custom_values, api) api.array :custom_fields do diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index b4b563a37..addcfdf62 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -31,10 +31,8 @@ <li><span class="label"><%=l(:label_subproject_plural)%>:</span> <%= @subprojects.collect{|p| link_to p, project_path(p)}.join(", ").html_safe %></li> <% end %> - <% @project.visible_custom_field_values.each do |custom_value| %> - <% if !custom_value.value.blank? %> - <li><span class="label"><%=h custom_value.custom_field.name %>:</span> <%=h show_value(custom_value) %></li> - <% end %> + <% render_custom_field_values(@project) do |custom_field, formatted| %> + <li><span class="label"><%= custom_field.name %>:</span> <%= formatted %></li> <% end %> </ul> diff --git a/app/views/versions/_overview.html.erb b/app/views/versions/_overview.html.erb index 616e1acdc..c3d359bb9 100644 --- a/app/views/versions/_overview.html.erb +++ b/app/views/versions/_overview.html.erb @@ -7,10 +7,8 @@ <p><%=h version.description %></p> <% if version.custom_field_values.any? %> <ul> - <% version.custom_field_values.each do |custom_value| %> - <% if custom_value.value.present? %> - <li><%=h custom_value.custom_field.name %>: <%=h show_value(custom_value) %></li> - <% end %> + <% render_custom_field_values(version) do |custom_field, formatted| %> + <li><span class="label"><%= custom_field.name %>:</span> <%= formatted %></li> <% end %> </ul> <% end %> |