<%--
/**
 * 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="/management_bar_display_buttons/init.jsp" %>

<%
String[] defaultViews = (String[])request.getAttribute("liferay-frontend:management-bar-display-buttons:defaultViews");
boolean disabled = GetterUtil.getBoolean(request.getAttribute("liferay-frontend:management-bar-display-buttons:disabled"));
String[] displayViews = (String[])request.getAttribute("liferay-frontend:management-bar-display-buttons:displayViews");
PortletURL portletURL = (PortletURL)request.getAttribute("liferay-frontend:management-bar-display-buttons:portletURL");
String selectedDisplayStyle = (String)request.getAttribute("liferay-frontend:management-bar-display-buttons:selectedDisplayStyle");

PortletURL displayStyleURL = PortletURLUtil.clone(portletURL, liferayPortletResponse);

for (String displayStyle : defaultViews) {
	String cssClass = StringPool.BLANK;

	if (displayStyle.equals("list")) {
		cssClass = "d-none d-sm-block";
	}

	displayStyleURL.setParameter("displayStyle", displayStyle);

	String icon = "table2";

	if (displayStyle.equals("descriptive")) {
		icon = "list";
	}
	else if (displayStyle.equals("icon")) {
		icon = "cards2";
	}
%>

	<liferay-frontend:management-bar-button
		active="<%= displayStyle.equals(selectedDisplayStyle) %>"
		cssClass="<%= cssClass %>"
		disabled="<%= disabled || !ArrayUtil.contains(displayViews, displayStyle) %>"
		href='<%= (disabled || !ArrayUtil.contains(displayViews, displayStyle)) ? "javascript:;" : displayStyleURL.toString() %>'
		icon="<%= icon %>"
		label="<%= displayStyle %>"
	/>

<%
}
%>