]> source.dussan.org Git - redmine.git/commitdiff
Refactor custom field value tag for custom fields with full text formatting enabled...
authorGo MAEDA <maeda@farend.jp>
Tue, 12 Feb 2019 11:52:20 +0000 (11:52 +0000)
committerGo MAEDA <maeda@farend.jp>
Tue, 12 Feb 2019 11:52:20 +0000 (11:52 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@17859 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/custom_fields_helper.rb
app/helpers/issues_helper.rb

index e0ca4529b7aa6024c353e28bd2ea62dec63eef5f..54573c763b448aa2cfe5701496f6581b8f19b7d2 100644 (file)
@@ -129,6 +129,17 @@ module CustomFieldsHelper
       :class => "#{custom_field.field_format}_cf"
   end
 
+  # Returns custom field value tag
+  def custom_field_value_tag(value)
+    attr_value = show_value(value)
+
+    if !attr_value.blank? && value.custom_field.full_text_formatting?
+      content_tag('div', attr_value, :class => 'wiki')
+    else
+      attr_value
+    end
+  end
+
   # Return a string used to display a custom value
   def show_value(custom_value, html=true)
     format_object(custom_value, html)
index 14d43f98e92f7e440508db674d6c163c198a7a8b..6bd8e292783bbd2fc7643f8d89c16ecda03b13b9 100644 (file)
@@ -244,12 +244,8 @@ module IssuesHelper
     issue_fields_rows do |rows|
       values.each_with_index do |value, i|
         css = "cf_#{value.custom_field.id}"
-        attr_value = show_value(value)
-        if value.custom_field.text_formatting == 'full'
-          attr_value = content_tag('div', attr_value, class: 'wiki')
-        end
         m = (i < half ? :left : :right)
-        rows.send m, custom_field_name_tag(value.custom_field), attr_value, :class => css
+        rows.send m, custom_field_name_tag(value.custom_field), custom_field_value_tag(value), :class => css
       end
     end
   end
@@ -260,17 +256,13 @@ module IssuesHelper
 
     s = ''.html_safe
     values.each_with_index do |value, i|
-      attr_value = show_value(value)
-      next if attr_value.blank?
-
-      if value.custom_field.text_formatting == 'full'
-        attr_value = content_tag('div', attr_value, class: 'wiki')
-      end
+      attr_value_tag = custom_field_value_tag(value)
+      next if attr_value_tag.blank?
 
       content =
           content_tag('hr') +
           content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field) )) +
-          content_tag('div', attr_value, class: 'value')
+          content_tag('div', attr_value_tag, class: 'value')
       s << content_tag('div', content, class: "cf_#{value.custom_field.id} attribute")
     end
     s