Class: QueryCustomFieldColumn

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

Overview

– copyright ChiliProject is a project management system.

Copyright (C) 2010-2013 the ChiliProject Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

See doc/COPYRIGHT.rdoc for more details. ++

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


17
18
19
20
21
22
23
24
25
# File 'app/models/query_custom_field_column.rb', line 17

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


27
28
29
# File 'app/models/query_custom_field_column.rb', line 27

def caption
  @cf.name
end

#custom_fieldObject


31
32
33
# File 'app/models/query_custom_field_column.rb', line 31

def custom_field
  @cf
end

#value(issue) ⇒ Object


35
36
37
38
# File 'app/models/query_custom_field_column.rb', line 35

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