Class: QueryColumn
- Inherits:
-
Object
- Object
- QueryColumn
- Includes:
- Redmine::I18n
- Defined in:
- app/models/query.rb
Overview
Redmine - project management software Copyright © 2006- 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
QueryAssociationColumn, QueryCustomFieldColumn, TimestampQueryColumn, WatcherQueryColumn
Instance Attribute Summary collapse
-
#default_order ⇒ Object
Returns the value of attribute default_order.
-
#groupable ⇒ Object
writeonly
Sets the attribute groupable.
-
#name ⇒ Object
Returns the value of attribute name.
- #sortable ⇒ Object
-
#totalable ⇒ Object
Returns the value of attribute totalable.
Instance Method Summary collapse
- #caption ⇒ Object
- #css_classes ⇒ Object
- #frozen? ⇒ Boolean
- #group_by_statement ⇒ Object
-
#group_value(object) ⇒ Object
Returns the group that object belongs to when grouping query results.
- #groupable? ⇒ Boolean
-
#initialize(name, options = {}) ⇒ QueryColumn
constructor
A new instance of QueryColumn.
- #inline? ⇒ Boolean
-
#sortable? ⇒ Boolean
Returns true if the column is sortable, otherwise false.
- #value(object) ⇒ Object
- #value_object(object) ⇒ Object
Methods included from Redmine::I18n
#abbr_day_name, #current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, included, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #normalize_float, #set_language_if_valid, #valid_languages
Constructor Details
#initialize(name, options = {}) ⇒ QueryColumn
Returns a new instance of QueryColumn.
26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/query.rb', line 26 def initialize(name, ={}) self.name = name self.sortable = [:sortable] self.groupable = [:groupable] || false self.totalable = [:totalable] || false self.default_order = [:default_order] @inline = .key?(:inline) ? [:inline] : true @caption_key = [:caption] || :"field_#{name}" @frozen = [:frozen] end |
Instance Attribute Details
#default_order ⇒ Object
Returns the value of attribute default_order.
21 22 23 |
# File 'app/models/query.rb', line 21 def default_order @default_order end |
#groupable=(value) ⇒ Object (writeonly)
Sets the attribute groupable
22 23 24 |
# File 'app/models/query.rb', line 22 def groupable=(value) @groupable = value end |
#name ⇒ Object
Returns the value of attribute name.
21 22 23 |
# File 'app/models/query.rb', line 21 def name @name end |
#sortable ⇒ Object
57 58 59 |
# File 'app/models/query.rb', line 57 def sortable @sortable.is_a?(Proc) ? @sortable.call : @sortable end |
#totalable ⇒ Object
Returns the value of attribute totalable.
21 22 23 |
# File 'app/models/query.rb', line 21 def totalable @totalable end |
Instance Method Details
#caption ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/query.rb', line 37 def case @caption_key when Symbol l(@caption_key) when Proc @caption_key.call else @caption_key end end |
#css_classes ⇒ Object
82 83 84 |
# File 'app/models/query.rb', line 82 def css_classes name end |
#frozen? ⇒ Boolean
65 66 67 |
# File 'app/models/query.rb', line 65 def frozen? @frozen end |
#group_by_statement ⇒ Object
86 87 88 |
# File 'app/models/query.rb', line 86 def group_by_statement name.to_s end |
#group_value(object) ⇒ Object
Returns the group that object belongs to when grouping query results
78 79 80 |
# File 'app/models/query.rb', line 78 def group_value(object) value(object) end |
#groupable? ⇒ Boolean
48 49 50 |
# File 'app/models/query.rb', line 48 def groupable? @groupable end |
#inline? ⇒ Boolean
61 62 63 |
# File 'app/models/query.rb', line 61 def inline? @inline end |
#sortable? ⇒ Boolean
Returns true if the column is sortable, otherwise false
53 54 55 |
# File 'app/models/query.rb', line 53 def sortable? @sortable.present? end |
#value(object) ⇒ Object
69 70 71 |
# File 'app/models/query.rb', line 69 def value(object) object.send name end |
#value_object(object) ⇒ Object
73 74 75 |
# File 'app/models/query.rb', line 73 def value_object(object) object.send name end |