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

<%
ResultRow row = (ResultRow)request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);

DDMFormInstance ddmFormInstance = (DDMFormInstance)row.getObject();

DateSearchEntry dateSearchEntry = new DateSearchEntry();

dateSearchEntry.setDate(ddmFormInstance.getModifiedDate());
%>

<div class="clamp-container">
	<h2 class="h5 text-truncate">

		<%
		boolean hasValidDDMFormFields = ddmFormAdminDisplayContext.hasValidDDMFormFields(ddmFormInstance);
		boolean hasValidStorageType = ddmFormAdminDisplayContext.hasValidStorageType(ddmFormInstance);
		%>

		<c:choose>
			<c:when test="<%= hasValidDDMFormFields && hasValidStorageType %>">
				<aui:a cssClass="form-instance-name" href="<%= (String)request.getAttribute(WebKeys.SEARCH_ENTRY_HREF) %>">
					<%= HtmlUtil.escape(ddmFormInstance.getName(locale)) %>
				</aui:a>
			</c:when>
			<c:otherwise>

				<%
				String errorMessage = StringPool.BLANK;

				if (!hasValidDDMFormFields) {
					errorMessage = LanguageUtil.format(request, "this-form-was-created-using-a-custom-field-type-x-that-is-not-available-for-this-liferay-dxp-installation.-instal-x-to-make-it-available-for-editing", ddmFormAdminDisplayContext.getInvalidDDMFormFieldType(ddmFormInstance));
				}
				else if (!hasValidStorageType) {
					errorMessage = LanguageUtil.format(request, "this-form-was-created-using-a-storage-type-x-that-is-not-available-for-this-liferay-dxp-installation.-install-x-to-make-it-available-for-editing", ddmFormInstance.getStorageType());
				}
				%>

				<span class="error-icon">
					<liferay-ui:icon
						icon="exclamation-full"
						markupView="lexicon"
						message="<%= errorMessage %>"
						toolTip="<%= true %>"
					/>
				</span>
				<span class="invalid-form-instance">
					<%= HtmlUtil.escape(ddmFormInstance.getName(locale)) %>
				</span>
			</c:otherwise>
		</c:choose>
	</h2>

	<span class="text-default">
		<div class="form-instance-description text-truncate">
			<%= HtmlUtil.escape(ddmFormInstance.getDescription(locale)) %>
		</div>
	</span>
	<span class="text-default">
		<span class="form-instance-id">
			<liferay-ui:message key="id" />: <%= ddmFormInstance.getFormInstanceId() %>
		</span>
		<span class="form-instance-modified-date">
			<liferay-ui:message key="modified-date" />: <%= dateSearchEntry.getName(request) %>
		</span>
	</span>
</div>