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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2019 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 = content_tag('div',
  25. content_tag('div', principals_check_box_tags('membership[user_ids][]', principals), :id => 'principals'),
  26. :class => 'objects-selection'
  27. )
  28. links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
  29. link_to text, autocomplete_project_memberships_path(project, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
  30. }
  31. s + content_tag('span', links, :class => 'pagination')
  32. end
  33. # Returns inheritance information for an inherited member role
  34. def render_role_inheritance(member, role)
  35. content = member.role_inheritance(role).map do |h|
  36. if h.is_a?(Project)
  37. l(:label_inherited_from_parent_project)
  38. elsif h.is_a?(Group)
  39. l(:label_inherited_from_group, :name => h.name.to_s)
  40. end
  41. end.compact.uniq
  42. if content.present?
  43. content_tag('span', content.join(", "), :class => "info")
  44. end
  45. end
  46. end