You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

queries_helper.rb 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # redMine - project management software
  2. # Copyright (C) 2006-2007 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. module QueriesHelper
  18. def operators_for_select(filter_type)
  19. Query.operators_by_filter_type[filter_type].collect {|o| [l(Query.operators[o]), o]}
  20. end
  21. def column_header(column)
  22. column.sortable ? sort_header_tag(column.name.to_s, :caption => column.caption,
  23. :default_order => column.default_order) :
  24. content_tag('th', column.caption)
  25. end
  26. def column_content(column, issue)
  27. if column.is_a?(QueryCustomFieldColumn)
  28. cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
  29. show_value(cv)
  30. else
  31. value = issue.send(column.name)
  32. if value.is_a?(Date)
  33. format_date(value)
  34. elsif value.is_a?(Time)
  35. format_time(value)
  36. else
  37. case column.name
  38. when :subject
  39. h((@project.nil? || @project != issue.project) ? "#{issue.project.name} - " : '') +
  40. link_to(h(value), :controller => 'issues', :action => 'show', :id => issue)
  41. when :done_ratio
  42. progress_bar(value, :width => '80px')
  43. else
  44. h(value)
  45. end
  46. end
  47. end
  48. end
  49. end