<%@ page contentType="text/html; charset=UTF-8"%><%@ include file="/WEB-INF/jspf/include/taglibs.jsp"%>

<%--
<c:if test="${not empty dashboardPaths}">
	<div class="dashboardPaths" >
		<c:forEach var="item" varStatus="status" items="${dashboardPaths}">
			<c:choose>
				<c:when test="${status.last}"><span style="font-size: 15pt;">${item.title}</span></c:when>
				<c:otherwise><a onclick="showBlock( 'dashboardRoot', 'list', { ...dashboardQuery, key: '${item.key}' } ); return false;">${item.title}</a> / </c:otherwise>
			</c:choose>
		</c:forEach>
	</div>
</c:if>
--%>

<ul class="dashboard">
<c:forEach var="item" items="${dashboardItems}">
	<c:set var="dashboardOnClick">
		<c:choose>
		<c:when test="${item.itemType == 'FOLDER'}">showDashboardBlock( { ...dashboardQuery, key: '${item.key}' } );</c:when>
		<c:when test="${item.itemType == 'LINK'}">window.location.href = '${item.url}'</c:when>
		<c:when test="${item.itemType == 'ASSISTANT_MASTER'}">window.location.href='${pageContext.request.contextPath}/webexecuter/p${item.moduleId}/Assistant?masterId=${item.assistantMasterId}'</c:when>
		<c:when test="${fn:startsWith( item.module, 'ru.bitel.bgbilling.plugins' )}">window.location.href ='${pageContext.request.contextPath}/webexecuter/p${item.moduleId}/${item.action}'</c:when>
		<c:when test="${item.moduleId > 0 }">window.location.href ='${pageContext.request.contextPath}/webexecuter/m${item.moduleId}/${item.action}'</c:when>
		<c:otherwise>window.location.href = '${pageContext.request.contextPath}/webexecuter?action=${item.action}&mid=${item.moduleId}&module=${item.module}&contractId=${contract.id}'</c:otherwise>
		<%--
		<c:otherwise>return showBlock( 'contentRoot', '', { action: '${item.action}', mid: '${item.moduleId}', module: '${item.module}', contractId: '${contract.id}', getBody: true } );</c:otherwise>
		<c:otherwise>window.location.href = '${pageContext.request.contextPath}/webexecuter?action=${item.action}&mid=${item.moduleId}&module=${item.module}&contractId=${contract.id}'</c:otherwise>
		 --%>
		</c:choose>
	</c:set>
	<c:if test="${item.itemType ne 'FOLDER'}">
	<c:set var="bg"><c:if test="${not empty item.icon}">background-attachment: fixed; background-image: url(${pageContext.request.contextPath}/${item.icon}); background-position: 30% 2rem; background-repeat: no-repeat;</c:if></c:set>
	<li class="tile tileHeight tilewMiddle" onclick="${dashboardOnClick}">
		<c:set var="bg"><c:if test="${not empty item.icon}">background-attachment: fixed; background-image: url(${pageContext.request.contextPath}/${item.icon}); background-position: 30% 2rem; background-repeat: no-repeat;</c:if></c:set>
		<div class="header bd-highlight">${item.title}</div>
		<div class="d-flex flex-row">
			<c:set var="iconSrc"><c:if test="${not empty item.icon}">${pageContext.request.contextPath}/${item.icon}</c:if></c:set>
			<div class="px-3 py-2"><img src="${iconSrc}" class="icon-color"></div>
			<c:set var="bodyText"><c:choose><c:when test="${not empty item.description}">${item.description}</c:when><c:otherwise><c:forEach var="subItems" varStatus="subStatus" items="${item.subItems}"><c:if test="${subStatus.index > 0}">, </c:if>${subItems.title}</c:forEach></c:otherwise></c:choose></c:set>
			<div class="body flex-fill"><c:choose><c:when test="${fn:length(bodyText) > 100}">${fn:substring(bodyText, 0, 100)}...</c:when><c:otherwise>${fn:substring(bodyText, 0, -1)}</c:otherwise></c:choose></div>
		</div>
	</li>
	</c:if>
</c:forEach>
</ul>

<script>

function showDashboardBlock( query )
{
	showBlock( 'contentRoot', 'list', query );
}

jQuery("#pageTitle").hide();

</script>
