<%--
/**
 * 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.
 *
 *
 *
 */
--%>

<aui:select label="scope" name="preferences--searchScope--" value="<%= searchDisplayContext.getSearchScopePreferenceString() %>">
	<aui:option label="this-site" value="this-site" />
	<aui:option label="everything" value="everything" />
	<aui:option label="let-the-user-choose" value="let-the-user-choose" />
</aui:select>

<liferay-frontend:fieldset-group>
	<span class="h3"><liferay-ui:message key="facets" /></span>

	<%
	List<SearchFacet> searchFacets = ListUtil.copy(searchDisplayContext.getSearchFacets());

	for (SearchFacet searchFacet : searchFacets) {
		searchFacet.init(company.getCompanyId(), searchDisplayContext.getSearchConfiguration());
	}

	searchFacets = ListUtil.sort(searchFacets, SearchFacetComparator.INSTANCE);

	for (SearchFacet searchFacet : searchFacets) {
	%>

		<liferay-frontend:fieldset
			collapsible="<%= true %>"
			id='<%= AUIUtil.normalizeId(searchFacet.getClassName()) + "FacetConfigurationPanel" %>'
			label="<%= searchFacet.getTitle() %>"
		>
			<aui:input label="enabled" name='<%= "preferences--" + searchFacet.getClassName() + "--" %>' type="checkbox" value="<%= searchDisplayContext.isDisplayFacet(searchFacet.getClassName()) %>" />

			<div class="facet-configuration" id="<portlet:namespace /><%= AUIUtil.normalizeId(searchFacet.getClassName()) %>FacetConfiguration" style="margin-left: 40px;">
				<div id="<%= StringUtil.replace(searchFacet.getClassName(), CharPool.PERIOD, CharPool.UNDERLINE) %>">

					<%
					request.setAttribute("facet_configuration.jsp-searchFacet", searchFacet);
					%>

					<div class="advance-configuration">
						<liferay-util:include page="/facets/facet_configuration.jsp" servletContext="<%= application %>" />
					</div>
				</div>
			</div>

			<hr />

			<aui:script>
				Liferay.Util.toggleBoxes(
					'<portlet:namespace /><%= AUIUtil.normalizeId(searchFacet.getClassName()) %>',
					'<portlet:namespace /><%= AUIUtil.normalizeId(searchFacet.getClassName()) %>FacetConfiguration'
				);
			</aui:script>
		</liferay-frontend:fieldset>

	<%
	}
	%>

</liferay-frontend:fieldset-group>