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

<%
SearchFacet searchFacet = (SearchFacet)request.getAttribute("facet_configuration.jsp-searchFacet");

JSONObject dataJSONObject = searchFacet.getData();

JSONArray rangesJSONArray = dataJSONObject.getJSONArray("ranges");
%>

<aui:fieldset id='<%= liferayPortletResponse.getNamespace() + "rangesId" %>'>

	<%
	int[] rangesIndexes = new int[rangesJSONArray.length()];

	for (int i = 0; i < rangesJSONArray.length(); i++) {
		rangesIndexes[i] = i;

		JSONObject jsonObject = rangesJSONArray.getJSONObject(i);
	%>

		<div class="lfr-form-row lfr-form-row-inline">
			<div class="row-fields">
				<aui:input label="label" name='<%= searchFacet.getClassName() + "label_" + i %>' value='<%= jsonObject.getString("label") %>' />

				<aui:input label="range" name='<%= searchFacet.getClassName() + "range_" + i %>' value='<%= jsonObject.getString("range") %>' />
			</div>
		</div>

	<%
	}
	%>

	<aui:input name='<%= searchFacet.getClassName() + "rangesIndexes" %>' type="hidden" value="<%= StringUtil.merge(rangesIndexes) %>" />
</aui:fieldset>

<aui:script use="liferay-auto-fields">
	var autoFields = new Liferay.AutoFields({
		contentBox: 'fieldset#<portlet:namespace />rangesId',
		fieldIndexes:
			'<portlet:namespace /><%= searchFacet.getClassName() %>rangesIndexes',
		namespace: '<portlet:namespace />',
	}).render();
</aui:script>