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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 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('div',
  32. content_tag('div', principals_check_box_tags('user_ids[]', principals), :id => 'principals'),
  33. :class => 'objects-selection'
  34. )
  35. links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
  36. link_to text, autocomplete_for_user_group_path(group, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
  37. }
  38. s + content_tag('span', links, :class => 'pagination')
  39. end
  40. end