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

<%
ViewDiscardDisplayContext viewDiscardDisplayContext = (ViewDiscardDisplayContext)request.getAttribute(CTWebKeys.VIEW_DISCARD_DISPLAY_CONTEXT);

portletDisplay.setURLBack(viewDiscardDisplayContext.getRedirectURL());

portletDisplay.setShowBackIcon(true);

renderResponse.setTitle(LanguageUtil.get(request, "discard-changes"));
%>

<clay:container-fluid
	cssClass="publications-discard-container"
>
	<div class="sheet">
		<clay:sheet-section>
			<clay:content-row>
				<clay:content-col
					expand="<%= true %>"
				>
					<h2 class="sheet-title"><liferay-ui:message key="discarded-changes" /></h2>
				</clay:content-col>

				<clay:content-col>
					<aui:input id="showHideable" inlineLabel="right" label='<%= LanguageUtil.get(request, "show-all-items") %>' name="show-hideable" onChange='<%= liferayPortletResponse.getNamespace() + "handleShowAllItemsToggleChange();" %>' type="toggle-switch" value="<%= viewDiscardDisplayContext.isShowHideable() %>" />
				</clay:content-col>
			</clay:content-row>

			<div class="sheet-text">
				<liferay-ui:message key="the-following-changes-will-be-discarded" />
			</div>

			<div>
				<react:component
					data="<%= viewDiscardDisplayContext.getReactData() %>"
					module="publications/js/ChangeTrackingDiscardView"
				/>
			</div>
		</clay:sheet-section>

		<clay:sheet-footer>
			<aui:button href="<%= viewDiscardDisplayContext.getSubmitURL() %>" primary="true" value="discard" />

			<aui:button href="<%= viewDiscardDisplayContext.getRedirectURL() %>" type="cancel" />
		</clay:sheet-footer>
	</div>
</clay:container-fluid>

<aui:script>
	function <portlet:namespace />handleShowAllItemsToggleChange() {
		var showHideableToggleState =
			'<%= !viewDiscardDisplayContext.isShowHideable() %>';

		let url = new URL(window.location.href);

		url.searchParams.set(
			'<portlet:namespace />showHideable',
			showHideableToggleState
		);

		window.location.href = url;
	}
</aui:script>