#-- $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>
<#-- 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>
<#-- For v1.3: The controller should pass in the dataservice url. -->
${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"> -->