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.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2021 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) +
  25. (tag.span(class: 'icon icon-user my-project', title: l(:label_my_projects)) if User.current.member_of?(item)) +
  26. (tag.span(class: 'icon icon-bookmarked-project', title: l(:label_my_bookmarks)) if User.current.bookmarked_project_ids.include?(item.id))
  27. when :short_description
  28. item.description? ? content_tag('div', textilizable(item, :short_description), :class => "wiki") : ''
  29. when :homepage
  30. item.homepage? ? content_tag('div', textilizable(item, :homepage), :class => "wiki") : ''
  31. when :status
  32. get_project_status_label[column.value_object(item)]
  33. when :parent_id
  34. link_to_project(item.parent) unless item.parent.nil?
  35. else
  36. super
  37. end
  38. end
  39. end
  40. def csv_value(column, object, value)
  41. if object.is_a?(Project)
  42. case column.name
  43. when :status
  44. get_project_status_label[column.value_object(object)]
  45. when :parent_id
  46. object.parent.name unless object.parent.nil?
  47. else
  48. super
  49. end
  50. end
  51. end
  52. private
  53. def get_project_status_label
  54. {
  55. Project::STATUS_ACTIVE => l(:project_status_active),
  56. Project::STATUS_CLOSED => l(:project_status_closed)
  57. }
  58. end
  59. end