Project

General

Profile

Defect #24473 ยป fix_cache_issues.patch

Stephane Evr, 2016-11-28 16:15

View differences:

app/helpers/application_helper.rb
170 170
  end
171 171

  
172 172
  # Helper that formats object for html or text rendering
173
  def format_object(object, html=true, &block)
173
  def format_object(object, html=true, originator=nil, &block)
174 174
    if block_given?
175 175
      object = yield object
176 176
    end
......
199 199
      object.visible? && html ? link_to_issue(object) : "##{object.id}"
200 200
    when 'CustomValue', 'CustomFieldValue'
201 201
      if object.custom_field
202
        f = object.custom_field.format.formatted_custom_value(self, object, html)
202
        f = object.custom_field.format.formatted_custom_value(self, object, html, originator)
203 203
        if f.nil? || f.is_a?(String)
204 204
          f
205 205
        else
app/helpers/custom_fields_helper.rb
120 120
  end
121 121

  
122 122
  # Return a string used to display a custom value
123
  def show_value(custom_value, html=true)
124
    format_object(custom_value, html)
123
  def show_value(custom_value, html=true, originator=nil)
124
    format_object(custom_value, html, originator)
125 125
  end
126 126

  
127 127
  # Return a string used to display a custom value
......
138 138
  # displayed, with the custom field and the formatted value as arguments
139 139
  def render_custom_field_values(object, &block)
140 140
    object.visible_custom_field_values.each do |custom_value|
141
      formatted = show_value(custom_value)
141
      formatted = show_value(custom_value, true, object)
142 142
      if formatted.present?
143 143
        yield custom_value.custom_field, formatted
144 144
      end
app/helpers/issues_helper.rb
228 228
      values.each_with_index do |value, i|
229 229
        css = "cf_#{value.custom_field.id}"
230 230
        m = (i < half ? :left : :right)
231
        rows.send m, custom_field_name_tag(value.custom_field), show_value(value), :class => css
231
        rows.send m, custom_field_name_tag(value.custom_field), show_value(value, true, issue), :class => css
232 232
      end
233 233
    end
234 234
  end
......
318 318
      end
319 319
    end
320 320
    issue.visible_custom_field_values(user).each do |value|
321
      items << "#{value.custom_field.name}: #{show_value(value, false)}"
321
      items << "#{value.custom_field.name}: #{show_value(value, false, issue)}"
322 322
    end
323 323
    items
324 324
  end
app/helpers/queries_helper.rb
152 152
        value.to_s(issue) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
153 153
        :class => value.css_classes_for(issue))
154 154
    else
155
      format_object(value)
155
      format_object(value, true, issue)
156 156
    end
157 157
  end
158 158

  
......
170 170
  end
171 171

  
172 172
  def csv_value(column, object, value)
173
    format_object(value, false) do |value|
173
    format_object(value, false, object) do |value|
174 174
      case value.class.name
175 175
      when 'Float'
176 176
        sprintf("%.2f", value).gsub('.', l(:general_csv_decimal_separator))
app/views/users/show.html.erb
14 14
  <% end %>
15 15
  <% @user.visible_custom_field_values.each do |custom_value| %>
16 16
  <% if !custom_value.value.blank? %>
17
    <li><%= custom_value.custom_field.name %>: <%= show_value(custom_value) %></li>
17
    <li><%= custom_value.custom_field.name %>: <%= show_value(custom_value, true, @user) %></li>
18 18
  <% end %>
19 19
  <% end %>
20 20
    <li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li>
lib/redmine/export/pdf/issues_pdf_helper.rb
70 70
  
71 71
          half = (issue.visible_custom_field_values.size / 2.0).ceil
72 72
          issue.visible_custom_field_values.each_with_index do |custom_value, i|
73
            (i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false)]
73
            (i < half ? left : right) << [custom_value.custom_field.name, show_value(custom_value, false, issue)]
74 74
          end
75 75
  
76 76
          if pdf.get_rtl
......
350 350
          query.inline_columns.collect do |column|
351 351
            s = if column.is_a?(QueryCustomFieldColumn)
352 352
              cv = issue.visible_custom_field_values.detect {|v| v.custom_field_id == column.custom_field.id}
353
              show_value(cv, false)
353
              show_value(cv, false, issue)
354 354
            else
355 355
              value = issue.send(column.name)
356 356
              if column.name == :subject
lib/redmine/field_format.rb
174 174
        []
175 175
      end
176 176

  
177
      def formatted_custom_value(view, custom_value, html=false)
178
        formatted_value(view, custom_value.custom_field, custom_value.value, custom_value.customized, html)
177
      def formatted_custom_value(view, custom_value, html=false, originator=nil)
178
        customized_obj = originator || custom_value.customized
179
        formatted_value(view, custom_value.custom_field, custom_value.value, customized_obj, html)
179 180
      end
180 181

  
181 182
      def formatted_value(view, custom_field, value, customized=nil, html=false)
    (1-1/1)