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.

members_helper.rb 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 MembersHelper
  19. def render_principals_for_new_members(project, limit=100)
  20. scope = Principal.active.visible.sorted.not_member_of(project).like(params[:q])
  21. principal_count = scope.count
  22. principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page']
  23. principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a
  24. s =
  25. content_tag(
  26. 'div',
  27. content_tag(
  28. 'div',
  29. principals_check_box_tags('membership[user_ids][]', principals),
  30. :id => 'principals'
  31. ),
  32. :class => 'objects-selection'
  33. )
  34. links =
  35. pagination_links_full(principal_pages,
  36. principal_count,
  37. :per_page_links => false) do |text, parameters, options|
  38. link_to(
  39. text,
  40. autocomplete_project_memberships_path(
  41. project,
  42. parameters.merge(:q => params[:q], :format => 'js')
  43. ),
  44. :remote => true)
  45. end
  46. s + content_tag('span', links, :class => 'pagination')
  47. end
  48. # Returns inheritance information for an inherited member role
  49. def render_role_inheritance(member, role)
  50. content = member.role_inheritance(role).map do |h|
  51. if h.is_a?(Project)
  52. l(:label_inherited_from_parent_project)
  53. elsif h.is_a?(Group)
  54. l(:label_inherited_from_group, :name => h.name.to_s)
  55. end
  56. end.compact.uniq
  57. if content.present?
  58. content_tag('em', content.join(", "), :class => "info")
  59. end
  60. end
  61. end