<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
--%>

<%@ include file="/init.jsp" %>

<%
ResultRow row = (ResultRow)request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);

Object[] objArray = (Object[])row.getObject();

Role role = (Role)objArray[0];
String target = (String)objArray[3];
Boolean supportsFilterByGroup = (Boolean)objArray[5];
long[] groupIdsArray = (long[])objArray[7];
List<String> groupNames = (List<String>)objArray[8];
String portletId = (String)objArray[9];
%>

<aui:input name='<%= "groupIds" + HtmlUtil.escapeAttribute(target) %>' type="hidden" value="<%= StringUtil.merge(groupIdsArray) %>" />
<aui:input name='<%= "groupNames" + HtmlUtil.escapeAttribute(target) %>' type="hidden" value='<%= StringUtil.merge(groupNames, "@@") %>' />

<div id="<portlet:namespace />groupDiv<%= HtmlUtil.escapeAttribute(target) %>">
	<span id="<portlet:namespace />groupHTML<%= HtmlUtil.escapeAttribute(target) %>">

		<%
		if (supportsFilterByGroup) {
			ItemSelector itemSelector = (ItemSelector)request.getAttribute(RolesAdminWebKeys.ITEM_SELECTOR);

			GroupItemSelectorCriterion groupItemSelectorCriterion = new GroupItemSelectorCriterion();

			groupItemSelectorCriterion.setAllowNavigation(false);
			groupItemSelectorCriterion.setDesiredItemSelectorReturnTypes(new URLItemSelectorReturnType());
			groupItemSelectorCriterion.setIncludeAllVisibleGroups(true);
			groupItemSelectorCriterion.setIncludeFormsSite(true);
			groupItemSelectorCriterion.setIncludeUserPersonalSite(true);
			groupItemSelectorCriterion.setPortletId(portletId);
			groupItemSelectorCriterion.setTarget(target);

			PortletURL itemSelectorURL = itemSelector.getItemSelectorURL(RequestBackedPortletURLFactoryUtil.create(liferayPortletRequest), liferayPortletResponse.getNamespace() + "selectGroup", groupItemSelectorCriterion);
		%>

			<react:component
				module="js/GroupLabels.es"
				props='<%=
					HashMapBuilder.<String, Object>put(
						"itemSelectorURL", itemSelectorURL.toString()
					).put(
						"target", target
					).build()
				%>'
			/>

		<%
		}
		else if (role.getType() == RoleConstants.TYPE_REGULAR) {
		%>

			<liferay-ui:message key="all-sites-and-asset-libraries" />

		<%
		}
		%>

	</span>
</div>