Project

General

Profile

Feature #29712 » 0002-Refactor-custom-field-value-tag-for-custom-fields-wi.patch

Marius BĂLTEANU, 2019-02-05 20:16

View differences:

app/helpers/custom_fields_helper.rb
129 129
      :class => "#{custom_field.field_format}_cf"
130 130
  end
131 131

  
132
  # Returns custom field value tag
133
  def custom_field_value_tag(value)
134
    attr_value = show_value(value)
135

  
136
    if !attr_value.blank? && value.custom_field.full_text_formatting?
137
      content_tag('div', attr_value, :class => 'wiki')
138
    else
139
      attr_value
140
    end
141
  end
142

  
132 143
  # Return a string used to display a custom value
133 144
  def show_value(custom_value, html=true)
134 145
    format_object(custom_value, html)
app/helpers/issues_helper.rb
244 244
    issue_fields_rows do |rows|
245 245
      values.each_with_index do |value, i|
246 246
        css = "cf_#{value.custom_field.id}"
247
        attr_value = show_value(value)
248
        if value.custom_field.text_formatting == 'full'
249
          attr_value = content_tag('div', attr_value, class: 'wiki')
250
        end
251 247
        m = (i < half ? :left : :right)
252
        rows.send m, custom_field_name_tag(value.custom_field), attr_value, :class => css
248
        rows.send m, custom_field_name_tag(value.custom_field), custom_field_value_tag(value), :class => css
253 249
      end
254 250
    end
255 251
  end
......
260 256

  
261 257
    s = ''.html_safe
262 258
    values.each_with_index do |value, i|
263
      attr_value = show_value(value)
264
      next if attr_value.blank?
265

  
266
      if value.custom_field.text_formatting == 'full'
267
        attr_value = content_tag('div', attr_value, class: 'wiki')
268
      end
259
      attr_value_tag = custom_field_value_tag(value)
260
      next if attr_value_tag.blank?
269 261

  
270 262
      content =
271 263
          content_tag('hr') +
272 264
          content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field) )) +
273
          content_tag('div', attr_value, class: 'value')
265
          content_tag('div', attr_value_tag, class: 'value')
274 266
      s << content_tag('div', content, class: "cf_#{value.custom_field.id} attribute")
275 267
    end
276 268
    s
(5-5/5)