@@ -128,7 +128,7 class CustomField < ActiveRecord::Base | |||
|
128 | 128 | |
|
129 | 129 | # Returns a ORDER BY clause that can used to sort customized |
|
130 | 130 | # objects by their value of the custom field. |
|
131 |
# Returns |
|
|
131 | # Returns nil if the custom field can not be used for sorting. | |
|
132 | 132 | def order_statement |
|
133 | 133 | return nil if multiple? |
|
134 | 134 | case field_format |
@@ -151,6 +151,18 class CustomField < ActiveRecord::Base | |||
|
151 | 151 | end |
|
152 | 152 | end |
|
153 | 153 | |
|
154 | # Returns a GROUP BY clause that can used to group by custom value | |
|
155 | # Returns nil if the custom field can not be used for grouping. | |
|
156 | def group_statement | |
|
157 | return nil if multiple? | |
|
158 | case field_format | |
|
159 | when 'list', 'date', 'bool', 'int' | |
|
160 | order_statement | |
|
161 | else | |
|
162 | nil | |
|
163 | end | |
|
164 | end | |
|
165 | ||
|
154 | 166 | def <=>(field) |
|
155 | 167 | position <=> field.position |
|
156 | 168 | end |
@@ -57,10 +57,7 class QueryCustomFieldColumn < QueryColumn | |||
|
57 | 57 | def initialize(custom_field) |
|
58 | 58 | self.name = "cf_#{custom_field.id}".to_sym |
|
59 | 59 | self.sortable = custom_field.order_statement || false |
|
60 | if %w(list date bool int).include?(custom_field.field_format) && !custom_field.multiple? | |
|
61 | self.groupable = custom_field.order_statement | |
|
62 | end | |
|
63 | self.groupable ||= false | |
|
60 | self.groupable = custom_field.group_statement || false | |
|
64 | 61 | @cf = custom_field |
|
65 | 62 | end |
|
66 | 63 |
General Comments 0
You need to be logged in to leave comments.
Login now