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.

projects_queries_helper.rb 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2017 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. module ProjectsQueriesHelper
  19. include ApplicationHelper
  20. def column_value(column, item, value)
  21. if item.is_a?(Project)
  22. case column.name
  23. when :name
  24. link_to_project(item) + (content_tag('span', '', :class => 'icon icon-user my-project', :title => l(:label_my_projects)) if User.current.member_of?(item))
  25. when :short_description
  26. item.description? ? content_tag('div', textilizable(item, :short_description), :class => "wiki") : ''
  27. when :homepage
  28. item.homepage? ? content_tag('div', textilizable(item, :homepage), :class => "wiki") : ''
  29. when :status
  30. get_project_status_label[column.value_object(item)]
  31. when :parent_id
  32. link_to_project(item.parent) unless item.parent.nil?
  33. else
  34. super
  35. end
  36. end
  37. end
  38. def csv_content(column, item)
  39. if item.is_a?(Project)
  40. case column.name
  41. when :status
  42. get_project_status_label[column.value_object(item)]
  43. when :parent_id
  44. return item.parent.name unless item.parent.nil?
  45. end
  46. end
  47. super
  48. end
  49. private
  50. def get_project_status_label
  51. {
  52. Project::STATUS_ACTIVE => l(:project_status_active),
  53. Project::STATUS_CLOSED => l(:project_status_closed)
  54. }
  55. end
  56. end