166 |
166 |
@available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values } unless user_values.empty?
|
167 |
167 |
|
168 |
168 |
if project
|
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] } }
|
171 |
|
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
|
|
169 |
# project specific filters
|
|
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
|
|
173 |
unless @project.versions.empty?
|
|
174 |
@available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.sort.collect{|s| [s.name, s.id.to_s] } }
|
|
175 |
end
|
172 |
176 |
unless @project.active_children.empty?
|
173 |
177 |
@available_filters["subproject_id"] = { :type => :list_subprojects, :order => 13, :values => @project.active_children.collect{|s| [s.name, s.id.to_s] } }
|
174 |
178 |
end
|
175 |
|
@project.all_custom_fields.select(&:is_filter?).each do |field|
|
176 |
|
case field.field_format
|
177 |
|
when "text"
|
178 |
|
options = { :type => :text, :order => 20 }
|
179 |
|
when "list"
|
180 |
|
options = { :type => :list_optional, :values => field.possible_values, :order => 20}
|
181 |
|
when "date"
|
182 |
|
options = { :type => :date, :order => 20 }
|
183 |
|
when "bool"
|
184 |
|
options = { :type => :list, :values => [[l(:general_text_yes), "1"], [l(:general_text_no), "0"]], :order => 20 }
|
185 |
|
else
|
186 |
|
options = { :type => :string, :order => 20 }
|
187 |
|
end
|
188 |
|
@available_filters["cf_#{field.id}"] = options.merge({ :name => field.name })
|
189 |
|
end
|
190 |
|
# remove category filter if no category defined
|
191 |
|
@available_filters.delete "category_id" if @available_filters["category_id"][:values].empty?
|
|
179 |
add_custom_fields_filters(@project.all_custom_fields)
|
|
180 |
else
|
|
181 |
# global filters for cross project issue list
|
|
182 |
add_custom_fields_filters(IssueCustomField.find(:all, :conditions => {:is_filter => true, :is_for_all => true}))
|
192 |
183 |
end
|
193 |
184 |
@available_filters
|
194 |
185 |
end
|
... | ... | |
366 |
357 |
|
367 |
358 |
(project_clauses + filters_clauses).join(' AND ')
|
368 |
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
|
369 |
382 |
end
|