Class: QueryColumn

Inherits:
Object
  • Object
show all
Includes:
Redmine::I18n
Defined in:
app/models/query.rb

Overview

Redmine - project management software Copyright (C) 2006-2014 Jean-Philippe Lang

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.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Direct Known Subclasses

QueryCustomFieldColumn

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Redmine::I18n

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

Constructor Details

#initialize(name, options = {}) ⇒ QueryColumn

Returns a new instance of QueryColumn.


22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/query.rb', line 22

def initialize(name, options={})
  self.name = name
  self.sortable = options[:sortable]
  self.groupable = options[:groupable] || false
  if groupable == true
    self.groupable = name.to_s
  end
  self.default_order = options[:default_order]
  @inline = options.key?(:inline) ? options[:inline] : true
  @caption_key = options[:caption] || "field_#{name}".to_sym
  @frozen = options[:frozen]
end

Instance Attribute Details

#default_orderObject

Returns the value of attribute default_order


19
20
21
# File 'app/models/query.rb', line 19

def default_order
  @default_order
end

#groupableObject

Returns the value of attribute groupable


19
20
21
# File 'app/models/query.rb', line 19

def groupable
  @groupable
end

#nameObject

Returns the value of attribute name


19
20
21
# File 'app/models/query.rb', line 19

def name
  @name
end

#sortableObject

Returns the value of attribute sortable


19
20
21
# File 'app/models/query.rb', line 19

def sortable
  @sortable
end

Instance Method Details

#captionObject


35
36
37
38
39
40
41
42
43
44
# File 'app/models/query.rb', line 35

def caption
  case @caption_key
  when Symbol
    l(@caption_key)
  when Proc
    @caption_key.call
  else
    @caption_key
  end
end

#css_classesObject


71
72
73
# File 'app/models/query.rb', line 71

def css_classes
  name
end

#frozen?Boolean

Returns:

  • (Boolean)

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

def frozen?
  @frozen
end

#inline?Boolean

Returns:

  • (Boolean)

55
56
57
# File 'app/models/query.rb', line 55

def inline?
  @inline
end

#sortable?Boolean

Returns true if the column is sortable, otherwise false

Returns:

  • (Boolean)

47
48
49
# File 'app/models/query.rb', line 47

def sortable?
  !@sortable.nil?
end

#value(object) ⇒ Object


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

def value(object)
  object.send name
end

#value_object(object) ⇒ Object


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

def value_object(object)
  object.send name
end