<%
/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library 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 Lesser General Public License for more
 * details.
 */
%>

<%
String taglibEnable = renderResponse.getNamespace() + "toggleEquitySection('#" + renderResponse.getNamespace() + "settings');";

boolean enabled = SocialEquityGroupSettingLocalServiceUtil.isEnabled(themeDisplay.getScopeGroupId(), Group.class.getName());
%>

<h4>
	<aui:input label="enable-social-equity" name="enabled" onClick="<%= taglibEnable %>" type="checkbox" value="<%= enabled %>" />
</h4>

<div class="<%= enabled ? StringPool.BLANK : "aui-helper-hidden" %>" id="<%= renderResponse.getNamespace() %>settings">

	<%
	Map<String, List<SocialEquityActionMapping>> equityActionMappingsMap = (Map<String, List<SocialEquityActionMapping>>)request.getAttribute(WebKeys.SOCIAL_EQUITY_ACTION_MAPPINGS_MAP);

	for (String className : equityActionMappingsMap.keySet()) {
		List<SocialEquityActionMapping> equityActionMappings = equityActionMappingsMap.get(className);

		taglibEnable = renderResponse.getNamespace() + "toggleEquitySection('#" + renderResponse.getNamespace() + StringUtil.replace(className, ".", "_") + "');";

		enabled = SocialEquityGroupSettingLocalServiceUtil.isEnabled(themeDisplay.getScopeGroupId(), className);
	%>

		<br />

		<h4>
			<aui:input label="<%= ResourceActionsUtil.getModelResource(locale, className) %>" name='<%= className + ".enabled" %>' onClick='<%= taglibEnable %>' type="checkbox" value="<%= enabled %>" />
		</h4>

		<div class="<%= enabled ? StringPool.BLANK : "aui-helper-hidden" %>" id="<%= renderResponse.getNamespace() + StringUtil.replace(className, ".", "_") %>">
			<br />

			<liferay-ui:search-container
				headerNames="name"
				iteratorURL="<%= portletURL %>"
			>
				<liferay-ui:search-container-results
					results="<%= equityActionMappings %>"
					total="<%= equityActionMappings.size() %>"
				/>

				<liferay-ui:search-container-row
					className="com.liferay.portlet.social.model.SocialEquityActionMapping"
					modelVar="equityActionMapping"
				>
					<liferay-ui:search-container-column-text
						name="name"
						value="<%= ResourceActionsUtil.getAction(locale, equityActionMapping.getActionId()) %>"
					/>

					<liferay-ui:search-container-column-text name="unique">
						<aui:input label="" name='<%= className + "." + equityActionMapping.getActionId() + ".unique" %>' type="checkbox" value="<%= equityActionMapping.isUnique() %>" />
					</liferay-ui:search-container-column-text>

					<liferay-ui:search-container-column-text name="information-value">
						<aui:input label="" name='<%= className + "." + equityActionMapping.getActionId() + ".informationValue" %>' size="4" type="text" value="<%= equityActionMapping.getInformationValue() %>" />
					</liferay-ui:search-container-column-text>

					<liferay-ui:search-container-column-text name="information-lifespan">
						<aui:input label="" name='<%= className + "." + equityActionMapping.getActionId() + ".informationLifespan" %>' size="4" type="text" value="<%= equityActionMapping.getInformationLifespan() %>" />
					</liferay-ui:search-container-column-text>

					<liferay-ui:search-container-column-text name="daily-limit">
						<aui:input label="" name='<%= className + "." + equityActionMapping.getActionId() + ".informationDailyLimit" %>' size="4" type="text" value="<%= equityActionMapping.getInformationDailyLimit() %>" />
					</liferay-ui:search-container-column-text>

					<liferay-ui:search-container-column-text name="participation-value">
						<aui:input label="" name='<%= className + "." + equityActionMapping.getActionId() + ".participationValue" %>' size="4" type="text" value="<%= equityActionMapping.getParticipationValue() %>" />
					</liferay-ui:search-container-column-text>

					<liferay-ui:search-container-column-text name="participation-lifespan">
						<aui:input label="" name='<%= className + "." + equityActionMapping.getActionId() + ".participationLifespan" %>' size="4" type="text" value="<%= equityActionMapping.getParticipationLifespan() %>" />
					</liferay-ui:search-container-column-text>

					<liferay-ui:search-container-column-text name="daily-limit">
						<aui:input label="" name='<%= className + "." + equityActionMapping.getActionId() + ".participationDailyLimit" %>' size="4" type="text" value="<%= equityActionMapping.getParticipationDailyLimit() %>" />
					</liferay-ui:search-container-column-text>
				</liferay-ui:search-container-row>

				<liferay-ui:search-iterator />
			</liferay-ui:search-container>
		</div>

	<%
	}
	%>

</div>

<aui:button-row>
	<aui:button type="submit" />
</aui:button-row>