Class: QueryCustomFieldColumn

Inherits:
QueryColumn show all
Defined in:
app/models/query.rb

Instance Attribute Summary

Attributes inherited from QueryColumn

#default_order, #groupable, #name, #sortable

Instance Method Summary collapse

Methods inherited from QueryColumn

#sortable?

Methods included from Redmine::I18n

#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages

Constructor Details

#initialize(custom_field) ⇒ QueryCustomFieldColumn

Returns a new instance of QueryCustomFieldColumn.



49
50
51
52
53
54
55
56
57
# File 'app/models/query.rb', line 49

def initialize(custom_field)
  self.name = "cf_#{custom_field.id}".to_sym
  self.sortable = custom_field.order_statement || false
  if %w(list date bool int).include?(custom_field.field_format)
    self.groupable = custom_field.order_statement
  end
  self.groupable ||= false
  @cf = custom_field
end

Instance Method Details

#captionObject



59
60
61
# File 'app/models/query.rb', line 59

def caption
  @cf.name
end

#custom_fieldObject



63
64
65
# File 'app/models/query.rb', line 63

def custom_field
  @cf
end

#value(issue) ⇒ Object



67
68
69
70
# File 'app/models/query.rb', line 67

def value(issue)
  cv = issue.custom_values.detect {|v| v.custom_field_id == @cf.id}
  cv && @cf.cast_value(cv.value)
end