<!--                                                                  -->
<!--  Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved     -->
<!--  $Id$  -->
<!--                                                                  -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:include href="/app/tools/common/production/templates/list_nav.xsl" />

    <xsl:template name="catalogListLayout">
        <div id="catalogMain">
            <div class="CatalogMain-wrapper">
                <section class="CatalogMain-section CatalogMain-section-main">
                    <div class="CatalogMain-section-col CatalogMain-section-col-view">
                        <xsl:call-template name="labelList" />
                    </div>
                </section>
            </div>        
        </div>
    </xsl:template>
    
    <xsl:template name="labelList">
        <div class="CatalogMain-albums-list">
            <div class="Table-controls Table-controls-top">
                <div class="Table-controls-item">
                    <xsl:if test="LabelList/Label">
                        <xsl:call-template name="labelSelectForm" />
                    </xsl:if>
                </div>
            </div>

            <xsl:call-template name="listTable">
                <xsl:with-param name="albums" select="/Root/AlbumList/Item/Album" />
                <xsl:with-param name="emptyMessage" select="'No albums are available under this heading.'" />
            </xsl:call-template>

            <xsl:if test="Pagination/TotalPages > 1">
                <div class="Table-controls Table-controls-bottom">
                    <div class="Table-controls-item Table-controls-item-pagination">
                        <xsl:call-template name="uiPagination">
                            <xsl:with-param name="lastPage" select="Pagination/TotalPages"/>
                            <xsl:with-param name="currentPage" select="Pagination/Current"/>
                            <xsl:with-param name="searchParams"><xsl:if test="/Root/Params/label">&amp;label=<xsl:value-of select="/Root/Params/label" /></xsl:if>&amp;c=list</xsl:with-param>
                        </xsl:call-template>
                    </div>
                </div>
            </xsl:if>
        </div>
    </xsl:template>

    <xsl:template name="listTable">
        <xsl:param name="albums" />
        <xsl:param name="emptyMessage" />

        <xsl:choose>
            <xsl:when test="$albums">
                <table class="Table Table-with-highlight">
                    <thead>
                        <xsl:call-template name="listHeaderRow" />
                    </thead>
                    <tbody>
                        <xsl:for-each select="$albums">
                            <xsl:call-template name="listRow" />
                        </xsl:for-each>
                    </tbody>
                </table>
            </xsl:when>
            <xsl:otherwise>
                <section class="Table-empty-results">
                    <p><xsl:value-of select="$emptyMessage" /></p>
                </section>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template name="listHeaderRow">
        <tr class="Table-row Table-row-header">
            <th class="Table-col CatalogMain-col-title">Title</th>
            <th class="Table-col CatalogMain-col-catalog">Catalog #</th>
            <th class="Table-col CatalogMain-col-artist">Artist</th>
            <xsl:if test="LabelList/Label">
                <th class="Table-col CatalogMain-col-label">Label</th>
            </xsl:if>
            <th class="Table-col CatalogMain-col-status">Status</th>
            <xsl:if test="Access/rps/catalog/edit or Access/rps/catalog/da_edit">
                <th class="Table-col Table-col-icon CatalogMain-col-edit">Edit</th>
            </xsl:if>
        </tr>
    </xsl:template>

    <xsl:template name="listRow">
        <tr class="Table-row Table-row-data">
            <td class="Table-col CatalogMain-col-title">
                <a href="catalog?AlbumID={AlbumID}&amp;c=show"><xsl:value-of select="Title" /><xsl:if test="TitleVersion != ''"> (<xsl:value-of select="TitleVersion" />)</xsl:if></a>
            </td>
            <td class="Table-col CatalogMain-col-catalog"><xsl:value-of select="CatalogNumber" /></td>
            <td class="Table-col CatalogMain-col-artist">
                <xsl:value-of select="ArtistName" />
                <xsl:if test="count(AdditionalArtistList/AdditionalArtist) != 0">
                    &#160;<a class="js-tooltip">
                        <xsl:attribute name="title">
                            <xsl:for-each select="AdditionalArtistList/AdditionalArtist">
                                <xsl:sort select="AdditionalArtistID" data-type="number" />
                                <xsl:call-template name="escapeJavascript">
                                    <xsl:with-param name="string" select="Name" />
                                </xsl:call-template> (<xsl:value-of select="Role/Role" />)<xsl:value-of select="$tipBreak" />
                            </xsl:for-each>
                        </xsl:attribute>
                        <xsl:call-template name="icon">
                            <xsl:with-param name="type" select="'more'" />
                        </xsl:call-template>
                    </a>
                </xsl:if>
            </td>
            <xsl:if test="/Root/LabelList/Label">
                <xsl:variable name="albumLabelID"><xsl:value-of select="LabelID" /></xsl:variable>
                <td class="Table-col CatalogMain-col-label">
                    <xsl:value-of select="/Root/LabelList/Label[LabelID = $albumLabelID]/LabelName" />
                </td>
            </xsl:if>
            <td class="Table-col CatalogMain-col-status">
                <xsl:call-template name="albumStatus">
                    <xsl:with-param name="status" select="Status" />
                </xsl:call-template>
            </td>

            <xsl:if test="/Root/Access/rps/catalog/edit or /Root/Access/rps/catalog/da_edit">
                <td class="Table-col Table-col-icon CatalogMain-col-edit">
                    <a href="catalog?c=edit&amp;AlbumID={AlbumID}" title="Edit" class="js-tooltip">
                       <xsl:call-template name="icon">
                            <xsl:with-param name="type" select="'edit'" />
                            <xsl:with-param name="role" select="'action'" />
                       </xsl:call-template>
                    </a>
                </td>
            </xsl:if>
        </tr>
    </xsl:template>    

</xsl:stylesheet>
