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.

groups_helper.rb 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006- 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 GroupsHelper
  19. def group_settings_tabs(group)
  20. tabs = []
  21. tabs << {:name => 'general', :partial => 'groups/general', :label => :label_general}
  22. tabs << {:name => 'users', :partial => 'groups/users', :label => :label_user_plural} if group.givable?
  23. tabs << {:name => 'memberships', :partial => 'groups/memberships', :label => :label_project_plural}
  24. tabs
  25. end
  26. def render_principals_for_new_group_users(group, limit=100)
  27. scope = User.active.sorted.not_in_group(group).like(params[:q])
  28. principal_count = scope.count
  29. principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page']
  30. principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a
  31. s = content_tag(
  32. 'div',
  33. content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals'),
  34. :class => 'objects-selection'
  35. )
  36. links =
  37. pagination_links_full(principal_pages, principal_count,
  38. :per_page_links => false) do |text, parameters, options|
  39. link_to(
  40. text,
  41. autocomplete_for_user_group_path(
  42. group,
  43. parameters.merge(:q => params[:q], :format => 'js')
  44. ),
  45. :remote => true
  46. )
  47. end
  48. s + content_tag('span', links, :class => 'pagination')
  49. end
  50. end