|
@@
-166,31
+166,20
class Query < ActiveRecord::Base
|
|
166
|
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
|
|
166
|
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
|
|
167
|
|
|
167
|
|
|
168
|
if project
|
|
168
|
if project
|
|
169
|
# project specific filters
|
|
169
|
# project specific filters
|
|
170
|
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
|
|
170
|
unless @project.issue_categories.empty?
|
|
|
|
|
171
|
@available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
|
|
|
|
|
172
|
end
|
|
171
|
unless @project.versions.empty?
|
|
173
|
unless @project.versions.empty?
|
|
172
|
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
|
|
174
|
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
|
|
173
|
end
|
|
175
|
end
|
|
174
|
unless @project.active_children.empty?
|
|
176
|
unless @project.active_children.empty?
|
|
175
|
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
|
|
177
|
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
|
|
176
|
end
|
|
178
|
end
|
|
177
|
@project.all_custom_fields.select(&:is_filter?).each do |field|
|
|
179
|
add_custom_fields_filters(@project.all_custom_fields)
|
|
178
|
case field.field_format
|
|
180
|
else
|
|
179
|
when "text"
|
|
181
|
# global filters for cross project issue list
|
|
180
|
options = { :type => :text, :order => 20 }
|
|
182
|
add_custom_fields_filters(IssueCustomField.find(:all, :conditions => {:is_filter => true, :is_for_all => true}))
|
|
181
|
when "list"
|
|
|
|
|
182
|
options = { :type => :list_optional, :values => field.possible_values, :order => 20}
|
|
|
|
|
183
|
when "date"
|
|
|
|
|
184
|
options = { :type => :date, :order => 20 }
|
|
|
|
|
185
|
when "bool"
|
|
|
|
|
186
|
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
|
|
|
|
187
|
else
|
|
|
|
|
188
|
options = { :type => :string, :order => 20 }
|
|
|
|
|
189
|
end
|
|
|
|
|
190
|
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
|
|
|
|
191
|
end
|
|
|
|
|
192
|
# remove category filter if no category defined
|
|
|
|
|
193
|
@available_filters.delete "category_id" if @available_filters["category_id"][:values].empty?
|
|
|
|
|
194
|
end
|
|
183
|
end
|
|
195
|
@available_filters
|
|
184
|
@available_filters
|
|
196
|
end
|
|
185
|
end
|
|
@@
-368,4
+357,26
class Query < ActiveRecord::Base
|
|
368
|
|
|
357
|
|
|
369
|
(project_clauses + filters_clauses).join(' AND ')
|
|
358
|
(project_clauses + filters_clauses).join(' AND ')
|
|
370
|
end
|
|
359
|
end
|
|
|
|
|
360
|
|
|
|
|
|
361
|
private
|
|
|
|
|
362
|
|
|
|
|
|
363
|
def add_custom_fields_filters(custom_fields)
|
|
|
|
|
364
|
@available_filters ||= {}
|
|
|
|
|
365
|
|
|
|
|
|
366
|
custom_fields.select(&:is_filter?).each do |field|
|
|
|
|
|
367
|
case field.field_format
|
|
|
|
|
368
|
when "text"
|
|
|
|
|
369
|
options = { :type => :text, :order => 20 }
|
|
|
|
|
370
|
when "list"
|
|
|
|
|
371
|
options = { :type => :list_optional, :values => field.possible_values, :order => 20}
|
|
|
|
|
372
|
when "date"
|
|
|
|
|
373
|
options = { :type => :date, :order => 20 }
|
|
|
|
|
374
|
when "bool"
|
|
|
|
|
375
|
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
|
|
|
|
376
|
else
|
|
|
|
|
377
|
options = { :type => :string, :order => 20 }
|
|
|
|
|
378
|
end
|
|
|
|
|
379
|
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
|
|
|
|
380
|
end
|
|
|
|
|
381
|
end
|
|
371
|
end
|
|
382
|
end
|