2019-03-16 09:37:35 +00:00
|
|
|
# frozen_string_literal: true
|
2019-03-15 01:32:57 +00:00
|
|
|
|
2011-08-31 08:41:25 +00:00
|
|
|
# Redmine - project management software
|
2024-02-26 22:55:54 +00:00
|
|
|
# Copyright (C) 2006- Jean-Philippe Lang
|
2007-03-12 17:59:02 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-08-31 08:41:25 +00:00
|
|
|
#
|
2007-03-12 17:59:02 +00:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
2011-08-31 08:41:25 +00:00
|
|
|
#
|
2007-03-12 17:59:02 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
2006-06-28 18:11:03 +00:00
|
|
|
module MembersHelper
|
2014-12-11 17:58:08 +00:00
|
|
|
def render_principals_for_new_members(project, limit=100)
|
2014-11-15 11:20:47 +00:00
|
|
|
scope = Principal.active.visible.sorted.not_member_of(project).like(params[:q])
|
2013-01-18 17:57:16 +00:00
|
|
|
principal_count = scope.count
|
2014-12-11 17:58:08 +00:00
|
|
|
principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page']
|
2014-10-22 17:37:16 +00:00
|
|
|
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).to_a
|
2020-09-26 15:02:18 +00:00
|
|
|
s =
|
|
|
|
|
content_tag(
|
|
|
|
|
'div',
|
|
|
|
|
content_tag(
|
2019-11-09 06:54:29 +00:00
|
|
|
'div',
|
2020-09-26 15:02:18 +00:00
|
|
|
principals_check_box_tags('membership[user_ids][]', principals),
|
|
|
|
|
:id => 'principals'
|
|
|
|
|
),
|
|
|
|
|
:class => 'objects-selection'
|
|
|
|
|
)
|
2019-11-09 05:24:46 +00:00
|
|
|
links =
|
|
|
|
|
pagination_links_full(principal_pages,
|
|
|
|
|
principal_count,
|
2020-11-07 12:30:15 +00:00
|
|
|
:per_page_links => false) do |text, parameters, options|
|
2019-11-09 05:24:46 +00:00
|
|
|
link_to(
|
|
|
|
|
text,
|
|
|
|
|
autocomplete_project_memberships_path(
|
|
|
|
|
project,
|
|
|
|
|
parameters.merge(:q => params[:q], :format => 'js')
|
|
|
|
|
),
|
|
|
|
|
:remote => true)
|
2020-11-07 12:30:15 +00:00
|
|
|
end
|
2015-11-28 11:13:15 +00:00
|
|
|
s + content_tag('span', links, :class => 'pagination')
|
2013-01-18 17:57:16 +00:00
|
|
|
end
|
2019-03-15 10:09:28 +00:00
|
|
|
|
2019-06-06 14:47:34 +00:00
|
|
|
# Returns inheritance information for an inherited member role
|
2019-03-15 10:09:28 +00:00
|
|
|
def render_role_inheritance(member, role)
|
2023-01-17 01:38:27 +00:00
|
|
|
content = member.role_inheritance(role).filter_map do |h|
|
2019-03-15 10:09:28 +00:00
|
|
|
if h.is_a?(Project)
|
|
|
|
|
l(:label_inherited_from_parent_project)
|
|
|
|
|
elsif h.is_a?(Group)
|
|
|
|
|
l(:label_inherited_from_group, :name => h.name.to_s)
|
|
|
|
|
end
|
2023-01-17 01:38:27 +00:00
|
|
|
end.uniq
|
2019-06-06 14:47:34 +00:00
|
|
|
|
2019-03-15 10:09:28 +00:00
|
|
|
if content.present?
|
2019-10-26 06:31:39 +00:00
|
|
|
content_tag('em', content.join(", "), :class => "info")
|
2019-03-15 10:09:28 +00:00
|
|
|
end
|
|
|
|
|
end
|
2006-06-28 18:11:03 +00:00
|
|
|
end
|