@@ -225,29 +225,41 class Query < ActiveRecord::Base | |||||
225 |
|
225 | |||
226 | def available_filters |
|
226 | def available_filters | |
227 | return @available_filters if @available_filters |
|
227 | return @available_filters if @available_filters | |
228 |
|
228 | @available_filters = { | ||
229 | @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } }, |
|
229 | "status_id" => { | |
230 | "tracker_id" => { :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } }, |
|
230 | :type => :list_status, :order => 1, | |
231 | "priority_id" => { :type => :list, :order => 3, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s] } }, |
|
231 | :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } | |
232 | "subject" => { :type => :text, :order => 8 }, |
|
232 | }, | |
233 | "created_on" => { :type => :date_past, :order => 9 }, |
|
233 | "tracker_id" => { | |
234 | "updated_on" => { :type => :date_past, :order => 10 }, |
|
234 | :type => :list, :order => 2, :values => trackers.collect{|s| [s.name, s.id.to_s] } | |
235 | "start_date" => { :type => :date, :order => 11 }, |
|
235 | }, | |
236 | "due_date" => { :type => :date, :order => 12 }, |
|
236 | "priority_id" => { | |
237 | "estimated_hours" => { :type => :float, :order => 13 }, |
|
237 | :type => :list, :order => 3, :values => IssuePriority.all.collect{|s| [s.name, s.id.to_s] } | |
238 | "done_ratio" => { :type => :integer, :order => 14 }} |
|
238 | }, | |
239 |
|
239 | "subject" => { :type => :text, :order => 8 }, | ||
|
240 | "created_on" => { :type => :date_past, :order => 9 }, | |||
|
241 | "updated_on" => { :type => :date_past, :order => 10 }, | |||
|
242 | "start_date" => { :type => :date, :order => 11 }, | |||
|
243 | "due_date" => { :type => :date, :order => 12 }, | |||
|
244 | "estimated_hours" => { :type => :float, :order => 13 }, | |||
|
245 | "done_ratio" => { :type => :integer, :order => 14 } | |||
|
246 | } | |||
240 | IssueRelation::TYPES.each do |relation_type, options| |
|
247 | IssueRelation::TYPES.each do |relation_type, options| | |
241 | @available_filters[relation_type] = {:type => :relation, :order => @available_filters.size + 100, :label => options[:name]} |
|
248 | @available_filters[relation_type] = { | |
|
249 | :type => :relation, :order => @available_filters.size + 100, | |||
|
250 | :label => options[:name] | |||
|
251 | } | |||
242 | end |
|
252 | end | |
243 |
|
||||
244 | principals = [] |
|
253 | principals = [] | |
245 | if project |
|
254 | if project | |
246 | principals += project.principals.sort |
|
255 | principals += project.principals.sort | |
247 | unless project.leaf? |
|
256 | unless project.leaf? | |
248 | subprojects = project.descendants.visible.all |
|
257 | subprojects = project.descendants.visible.all | |
249 | if subprojects.any? |
|
258 | if subprojects.any? | |
250 | @available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => subprojects.collect{|s| [s.name, s.id.to_s] } } |
|
259 | @available_filters["subproject_id"] = { | |
|
260 | :type => :list_subprojects, :order => 13, | |||
|
261 | :values => subprojects.collect{|s| [s.name, s.id.to_s] } | |||
|
262 | } | |||
251 | principals += Principal.member_of(subprojects) |
|
263 | principals += Principal.member_of(subprojects) | |
252 | end |
|
264 | end | |
253 | end |
|
265 | end | |
@@ -255,14 +267,15 class Query < ActiveRecord::Base | |||||
255 | if all_projects.any? |
|
267 | if all_projects.any? | |
256 | # members of visible projects |
|
268 | # members of visible projects | |
257 | principals += Principal.member_of(all_projects) |
|
269 | principals += Principal.member_of(all_projects) | |
258 |
|
||||
259 | # project filter |
|
270 | # project filter | |
260 | project_values = [] |
|
271 | project_values = [] | |
261 | if User.current.logged? && User.current.memberships.any? |
|
272 | if User.current.logged? && User.current.memberships.any? | |
262 | project_values << ["<< #{l(:label_my_projects).downcase} >>", "mine"] |
|
273 | project_values << ["<< #{l(:label_my_projects).downcase} >>", "mine"] | |
263 | end |
|
274 | end | |
264 | project_values += all_projects_values |
|
275 | project_values += all_projects_values | |
265 | @available_filters["project_id"] = { :type => :list, :order => 1, :values => project_values} unless project_values.empty? |
|
276 | @available_filters["project_id"] = { | |
|
277 | :type => :list, :order => 1, :values => project_values | |||
|
278 | } unless project_values.empty? | |||
266 | end |
|
279 | end | |
267 | end |
|
280 | end | |
268 | principals.uniq! |
|
281 | principals.uniq! | |
@@ -271,59 +284,84 class Query < ActiveRecord::Base | |||||
271 |
|
284 | |||
272 | assigned_to_values = [] |
|
285 | assigned_to_values = [] | |
273 | assigned_to_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged? |
|
286 | assigned_to_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged? | |
274 |
assigned_to_values += (Setting.issue_group_assignment? ? |
|
287 | assigned_to_values += (Setting.issue_group_assignment? ? | |
275 | @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => assigned_to_values } unless assigned_to_values.empty? |
|
288 | principals : users).collect{|s| [s.name, s.id.to_s] } | |
|
289 | @available_filters["assigned_to_id"] = { | |||
|
290 | :type => :list_optional, :order => 4, :values => assigned_to_values | |||
|
291 | } unless assigned_to_values.empty? | |||
276 |
|
292 | |||
277 | author_values = [] |
|
293 | author_values = [] | |
278 | author_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged? |
|
294 | author_values << ["<< #{l(:label_me)} >>", "me"] if User.current.logged? | |
279 | author_values += users.collect{|s| [s.name, s.id.to_s] } |
|
295 | author_values += users.collect{|s| [s.name, s.id.to_s] } | |
280 | @available_filters["author_id"] = { :type => :list, :order => 5, :values => author_values } unless author_values.empty? |
|
296 | @available_filters["author_id"] = { | |
|
297 | :type => :list, :order => 5, :values => author_values | |||
|
298 | } unless author_values.empty? | |||
281 |
|
299 | |||
282 | group_values = Group.all.collect {|g| [g.name, g.id.to_s] } |
|
300 | group_values = Group.all.collect {|g| [g.name, g.id.to_s] } | |
283 | @available_filters["member_of_group"] = { :type => :list_optional, :order => 6, :values => group_values } unless group_values.empty? |
|
301 | @available_filters["member_of_group"] = { | |
|
302 | :type => :list_optional, :order => 6, :values => group_values | |||
|
303 | } unless group_values.empty? | |||
284 |
|
304 | |||
285 | role_values = Role.givable.collect {|r| [r.name, r.id.to_s] } |
|
305 | role_values = Role.givable.collect {|r| [r.name, r.id.to_s] } | |
286 | @available_filters["assigned_to_role"] = { :type => :list_optional, :order => 7, :values => role_values } unless role_values.empty? |
|
306 | @available_filters["assigned_to_role"] = { | |
|
307 | :type => :list_optional, :order => 7, :values => role_values | |||
|
308 | } unless role_values.empty? | |||
287 |
|
309 | |||
288 | if User.current.logged? |
|
310 | if User.current.logged? | |
289 | @available_filters["watcher_id"] = { :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] } |
|
311 | @available_filters["watcher_id"] = { | |
|
312 | :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] | |||
|
313 | } | |||
290 | end |
|
314 | end | |
291 |
|
315 | |||
292 | if project |
|
316 | if project | |
293 | # project specific filters |
|
317 | # project specific filters | |
294 | categories = project.issue_categories.all |
|
318 | categories = project.issue_categories.all | |
295 | unless categories.empty? |
|
319 | unless categories.empty? | |
296 | @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => categories.collect{|s| [s.name, s.id.to_s] } } |
|
320 | @available_filters["category_id"] = { | |
|
321 | :type => :list_optional, :order => 6, | |||
|
322 | :values => categories.collect{|s| [s.name, s.id.to_s] } | |||
|
323 | } | |||
297 | end |
|
324 | end | |
298 | versions = project.shared_versions.all |
|
325 | versions = project.shared_versions.all | |
299 | unless versions.empty? |
|
326 | unless versions.empty? | |
300 | @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } } |
|
327 | @available_filters["fixed_version_id"] = { | |
|
328 | :type => :list_optional, :order => 7, | |||
|
329 | :values => versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } | |||
|
330 | } | |||
301 | end |
|
331 | end | |
302 | add_custom_fields_filters(project.all_issue_custom_fields) |
|
332 | add_custom_fields_filters(project.all_issue_custom_fields) | |
303 | else |
|
333 | else | |
304 | # global filters for cross project issue list |
|
334 | # global filters for cross project issue list | |
305 | system_shared_versions = Version.visible.find_all_by_sharing('system') |
|
335 | system_shared_versions = Version.visible.find_all_by_sharing('system') | |
306 | unless system_shared_versions.empty? |
|
336 | unless system_shared_versions.empty? | |
307 | @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => system_shared_versions.sort.collect{|s| ["#{s.project.name} - #{s.name}", s.id.to_s] } } |
|
337 | @available_filters["fixed_version_id"] = { | |
|
338 | :type => :list_optional, :order => 7, | |||
|
339 | :values => system_shared_versions.sort.collect{|s| | |||
|
340 | ["#{s.project.name} - #{s.name}", s.id.to_s] | |||
|
341 | } | |||
|
342 | } | |||
308 | end |
|
343 | end | |
309 | add_custom_fields_filters(IssueCustomField.find(:all, :conditions => {:is_filter => true, :is_for_all => true})) |
|
344 | add_custom_fields_filters( | |
|
345 | IssueCustomField.find(:all, | |||
|
346 | :conditions => { | |||
|
347 | :is_filter => true, | |||
|
348 | :is_for_all => true | |||
|
349 | })) | |||
310 | end |
|
350 | end | |
311 |
|
||||
312 | add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version |
|
351 | add_associations_custom_fields_filters :project, :author, :assigned_to, :fixed_version | |
313 |
|
||||
314 | if User.current.allowed_to?(:set_issues_private, nil, :global => true) || |
|
352 | if User.current.allowed_to?(:set_issues_private, nil, :global => true) || | |
315 | User.current.allowed_to?(:set_own_issues_private, nil, :global => true) |
|
353 | User.current.allowed_to?(:set_own_issues_private, nil, :global => true) | |
316 | @available_filters["is_private"] = { :type => :list, :order => 15, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]] } |
|
354 | @available_filters["is_private"] = { | |
|
355 | :type => :list, :order => 15, | |||
|
356 | :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]] | |||
|
357 | } | |||
317 | end |
|
358 | end | |
318 |
|
||||
319 | Tracker.disabled_core_fields(trackers).each {|field| |
|
359 | Tracker.disabled_core_fields(trackers).each {|field| | |
320 | @available_filters.delete field |
|
360 | @available_filters.delete field | |
321 | } |
|
361 | } | |
322 |
|
||||
323 | @available_filters.each do |field, options| |
|
362 | @available_filters.each do |field, options| | |
324 | options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, '')) |
|
363 | options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, '')) | |
325 | end |
|
364 | end | |
326 |
|
||||
327 | @available_filters |
|
365 | @available_filters | |
328 | end |
|
366 | end | |
329 |
|
367 |
General Comments 0
You need to be logged in to leave comments.
Login now