Project

General

Profile

Defect #34743 » queries_helper.patch

Alexander Meindl, 2021-02-14 08:06

View differences:

app/helpers/queries_helper.rb
229 229

  
230 230
  def column_content(column, item)
231 231
    value = column.value_object(item)
232
    if value.is_a?(Array)
233
      values = value.collect {|v| column_value(column, item, v)}.compact
234
      safe_join(values, ', ')
235
    else
236
      column_value(column, item, value)
237
    end
232
    content = if value.is_a?(Array)
233
                values = value.collect {|v| column_value(column, item, v)}.compact
234
                safe_join(values, ', ')
235
              else
236
                column_value(column, item, value)
237
              end
238

  
239
    call_hook(:helper_queries_column_content,
240
              {:content => content, :column => column, :item => item})
241

  
242
    content
238 243
  end
239 244

  
240 245
  def column_value(column, item, value)
241
    case column.name
242
    when :id
243
      link_to value, issue_path(item)
244
    when :subject
245
      link_to value, issue_path(item)
246
    when :parent
247
      value ? (value.visible? ? link_to_issue(value, :subject => false) : "##{value.id}") : ''
248
    when :description
249
      item.description? ? content_tag('div', textilizable(item, :description), :class => "wiki") : ''
250
    when :last_notes
251
      item.last_notes.present? ? content_tag('div', textilizable(item, :last_notes), :class => "wiki") : ''
252
    when :done_ratio
253
      progress_bar(value)
254
    when :relations
255
      content_tag(
256
        'span',
257
        value.to_s(item) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
258
        :class => value.css_classes_for(item))
259
    when :hours, :estimated_hours, :total_estimated_hours
260
      format_hours(value)
261
    when :spent_hours
262
      link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "#{item.id}"))
263
    when :total_spent_hours
264
      link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "~#{item.id}"))
265
    when :attachments
266
      value.to_a.map {|a| format_object(a)}.join(" ").html_safe
267
    else
268
      format_object(value)
269
    end
246
    content = case column.name
247
              when :id
248
                link_to value, issue_path(item)
249
              when :subject
250
                link_to value, issue_path(item)
251
              when :parent
252
                value ? (value.visible? ? link_to_issue(value, :subject => false) : "##{value.id}") : ''
253
              when :description
254
                item.description? ? content_tag('div', textilizable(item, :description), :class => "wiki") : ''
255
              when :last_notes
256
                item.last_notes.present? ? content_tag('div', textilizable(item, :last_notes), :class => "wiki") : ''
257
              when :done_ratio
258
                progress_bar(value)
259
              when :relations
260
                content_tag(
261
                  'span',
262
                  value.to_s(item) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
263
                  :class => value.css_classes_for(item))
264
              when :hours, :estimated_hours, :total_estimated_hours
265
                format_hours(value)
266
              when :spent_hours
267
                link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "#{item.id}"))
268
              when :total_spent_hours
269
                link_to_if(value > 0, format_hours(value), project_time_entries_path(item.project, :issue_id => "~#{item.id}"))
270
              when :attachments
271
                value.to_a.map {|a| format_object(a)}.join(" ").html_safe
272
              else
273
                format_object(value)
274
              end
275

  
276
    call_hook(:helper_queries_column_value,
277
              {:content => content, :column => column, :item => item, :value => value})
278

  
279
    content
270 280
  end
271 281

  
272 282
  def csv_content(column, item)
(1-1/2)