#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<#-- Browse class groups on the home page. Could potentially become a widget -->
${stylesheets.add("/css/browseClassGroups.css")}
<#macro allClassGroups classGroups>
<#-- Loop through classGroups first so we can account for situations when all class groups are empty -->
<#assign selected = 'class="selected" ' />
<#assign classGroupList>
<#list classGroups as group>
<#-- Only display populated class groups -->
<#if (group.individualCount > 0)>
<#-- Catch the first populated class group. Will be used later as the default selected class group -->
<#if !firstPopulatedClassGroup??>
<#assign firstPopulatedClassGroup = group />
#if>
<#-- Remove "index.jsp" from URL (should verify with RY if this can be taken care of in the controller) -->
<#if currentPage == "index.jsp">
<#assign currentPage = "" />
#if>
<#-- Determine the active (selected) group -->
<#assign activeGroup = "" />
<#if !classGroup??>
<#if group_index == 0>
<#assign activeGroup = selected />
#if>
<#elseif classGroup.uri == group.uri>
<#assign activeGroup = selected />
#if>
#if>
#list>
#assign>
<#-- Display the class group browse only if we have at least one populated class group -->
<#if firstPopulatedClassGroup??>
Browse by
${classGroupList}
<#-- If requesting the home page without any additional URL parameters, select the first populated class group-->
<#assign defaultSelectedClassGroup = firstPopulatedClassGroup />
<#if classes??>
<#-- We don't need to send parameters because the data we need is delivered as template variables -->
<@visualGraph />
<#else>
<#-- We need to pass the data to the macro because the only template variable provided by default is classGroups -->
<@visualGraph classes=defaultSelectedClassGroup.classes classGroup=defaultSelectedClassGroup />
#if>
<#----------------------------------------------------------------------------------
requestedPage is currently provided by FreemarkerHttpServlet. Should this be moved
to PageController? Maybe we should have Java provide the domain name directly
instead of the full URL of the requested page? Chintan was also asking for a
template variable with the domain name for an AJAX request with visualizations.
------------------------------------------------------------------------------------>
<#assign domainName = requestedPage?substring(0, requestedPage?index_of("/", 7)) />
${scripts.add("/js/browseClassGroups.js")}
<#else>
<#-- Would be nice to update classgroups-checkForData.ftl with macro so it could be used here as well -->
<#-- <#include "classgroups-checkForData.ftl"> -->