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

<%
PortletURL portletURL = PortletURLBuilder.create(
	currentURLObj
).setParameter(
	"historyKey", liferayPortletResponse.getNamespace() + "images"
).buildPortletURL();

CategoryCPAttachmentFileEntriesManagementToolbarDisplayContext categoryCPAttachmentFileEntriesManagementToolbarDisplayContext = new CategoryCPAttachmentFileEntriesManagementToolbarDisplayContext(request, liferayPortletRequest, liferayPortletResponse, portletURL);
%>

<clay:management-toolbar
	managementToolbarDisplayContext="<%= categoryCPAttachmentFileEntriesManagementToolbarDisplayContext %>"
/>

<clay:container-fluid>
	<liferay-ui:search-container
		emptyResultsMessage="there-are-no-images"
		id="cpAttachmentFileEntries"
		searchContainer="<%= categoryCPAttachmentFileEntriesManagementToolbarDisplayContext.getSearchContainer() %>"
	>
		<liferay-ui:search-container-row
			className="com.liferay.commerce.product.model.CPAttachmentFileEntry"
			keyProperty="CPAttachmentFileEntryId"
			modelVar="cpAttachmentFileEntry"
		>

			<%
			String thumbnailSrc = StringPool.BLANK;

			FileEntry fileEntry = cpAttachmentFileEntry.fetchFileEntry();

			if (fileEntry == null) {
				thumbnailSrc = cpAttachmentFileEntry.getCDNURL();
			}
			else {
				thumbnailSrc = CommerceMediaResolverUtil.getThumbnailURL(CommerceAccountConstants.ACCOUNT_ID_GUEST, cpAttachmentFileEntry.getCPAttachmentFileEntryId());
			}
			%>

			<c:choose>
				<c:when test="<%= Validator.isNotNull(thumbnailSrc) %>">
					<liferay-ui:search-container-column-image
						name="image"
						src="<%= thumbnailSrc %>"
					/>
				</c:when>
				<c:otherwise>
					<liferay-ui:search-container-column-icon
						icon="documents-and-media"
					/>
				</c:otherwise>
			</c:choose>

			<liferay-ui:search-container-column-text
				cssClass="table-cell-expand"
				name="title"
				value="<%= HtmlUtil.escape(cpAttachmentFileEntry.getTitle(languageId)) %>"
			/>

			<liferay-ui:search-container-column-text
				cssClass="table-cell-expand-smallest table-cell-ws-nowrap"
				name="extension"
				value="<%= HtmlUtil.escape(fileEntry.getExtension()) %>"
			/>

			<liferay-ui:search-container-column-text
				cssClass="table-cell-expand-smallest table-cell-ws-nowrap"
				property="priority"
			/>

			<liferay-ui:search-container-column-status
				cssClass="table-cell-expand-smallest table-cell-ws-nowrap"
				name="status"
				status="<%= cpAttachmentFileEntry.getStatus() %>"
			/>

			<liferay-ui:search-container-column-date
				cssClass="table-cell-expand-smallest table-cell-ws-nowrap"
				name="modified-date"
				property="modifiedDate"
			/>

			<liferay-ui:search-container-column-date
				cssClass="table-cell-expand-smallest table-cell-ws-nowrap"
				name="display-date"
				property="displayDate"
			/>

			<liferay-ui:search-container-column-jsp
				path="/image_action.jsp"
			/>
		</liferay-ui:search-container-row>

		<liferay-ui:search-iterator
			markupView="lexicon"
		/>
	</liferay-ui:search-container>
</clay:container-fluid>