view gnv/src/main/webapp/WEB-INF/config/templates/describe-ui.xsl @ 1002:b1eea43ba133

Second attempt to apply redirect link patch. gnv/trunk@1206 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 13 Jun 2010 16:28:37 +0000
parents 27029f0ec7e1
children a0d16ccb82ba
line wrap: on
line source
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns="http://www.w3.org/2002/xforms" 
                xmlns:xform="http://www.w3.org/2002/xforms" 
                xmlns:art="http://www.intevation.de/2009/artifacts"
                exclude-result-prefixes="xform art">

    <xsl:output
        method="html" version="1.0" encoding="UTF-8" omit-xml-declaration="no" />

    <xsl:param name="example-linestring"/>
    <xsl:param name="example-polygon"/>
    <xsl:param name="uuid"/>
    <xsl:param name="next-url">/gnv/next.do</xsl:param>
    <xsl:param name="further">false</xsl:param>
    <xsl:param name="exception"/>
    <xsl:param name="gnviewer-select-button-src">./images/auswaehlen.png</xsl:param>

    <xsl:template match="art:ui">
        <xsl:if test="$further = 'true'">
            <div id="timeseriesfilter"> 
                <form id="fisSelectionForm" 
                      onsubmit="displayOverlay()" 
                      action="{$next-url}" 
                      method="post">
                <fieldset>
                    <xsl:if test="$exception != ''">
                        <div class="inputException"><xsl:value-of select="$exception"/></div>
                    </xsl:if>
                    <input type="hidden" name="artifact-uuid" value="{$uuid}"/>
                    <xsl:apply-templates select="art:dynamic"/>
                    <xsl:variable name="item-count" select="count(art:dynamic//xform:select1//xform:item)"/>
                    <xsl:if test="$item-count = 0 or $item-count &gt; 5">
                        <br/> 
                        <input style="margin-top: 5px;" type="image" src="{$gnviewer-select-button-src}"/>
                    </xsl:if>
                </fieldset>
                </form>
            </div>
        </xsl:if>
    </xsl:template>

    <!-- single select -->
    <xsl:template match="xform:select1" >
        <xsl:variable name="selectName" select="@ref"/>
        <xsl:variable name="items" select="count(.//xform:item)"/>
        <legend><xsl:value-of select="xform:label"/></legend>
        <xsl:choose>
            <xsl:when test="$items &lt; 6">
                <xsl:apply-templates mode="direct-link"/>
            </xsl:when>
            <xsl:otherwise>
                <select name="{$selectName}">
                    <xsl:apply-templates />
                </select>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <xsl:template match="text()" mode="direct-link"/>

    <!-- options for select: direct-link -->
    <xsl:template match="xform:item" mode="direct-link">
        <xsl:variable name="optionValue" select="xform:value"/>
        <xsl:variable name="selectName" select="ancestor::xform:select1/@ref"/>
        <a class="linkButton"
            onclick="displayOverlay()"
            href="{$next-url}?{$selectName}={$optionValue}"><xsl:value-of select="xform:label"/></a>
        <br/>
        <br/>
    </xsl:template>

    <!-- multi select -->
    <xsl:template match="xform:select">
        <xsl:variable name="selectName" select="@ref"/>
        <xsl:variable name="items" select="count(.//xform:item)"/>
        <legend>
            <xsl:value-of select="xform:label"/>
        </legend>

        <xsl:choose>
            <xsl:when test="$items = 1">
                <select name="{$selectName}" multiple="multiple" size="{$items}">
                    <xsl:apply-templates mode="selected"/>
                </select>
            </xsl:when>
            <xsl:when test="$items &lt; 5">
                <select name="{$selectName}" multiple="multiple" size="{$items}">
                    <xsl:apply-templates/>
                </select>
            </xsl:when>
            <xsl:otherwise>
                <select name="{$selectName}" multiple="multiple" size="5">
                    <xsl:apply-templates />
                </select>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- options for select -->
    <xsl:template match="xform:item">
        <xsl:variable name="optionValue" select="xform:value"/>
        <xsl:choose>
            <xsl:when test="@selected = 'true'">
                <option value="{$optionValue}" selected="selected">
                    <xsl:value-of select="xform:label"/>
                </option>
            </xsl:when>
            <xsl:otherwise>
                <option value="{$optionValue}">
                    <xsl:value-of select="xform:label"/>
                </option>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <xsl:template match="xform:item" mode="selected">
        <xsl:variable name="optionValue" select="xform:value"/>
            <option value="{$optionValue}" selected="selected">
                <xsl:value-of select="xform:label"/>
            </option>
    </xsl:template>



    <xsl:template match="xform:group">
        <xsl:variable name="selectcount" select="count(xform:select)"/>

        <legend>
            <xsl:value-of select="xform:label"/>
        </legend>

        <xsl:choose>
            <xsl:when test="$selectcount &lt; '1'">
                <table class="dynamic">
                    <xsl:apply-templates/>
                </table>
            </xsl:when>
            <xsl:otherwise>
                <table class="static">
                    <tr>
                        <td><!-- nothing here --></td>
                        <!-- take the first select node to render column labels -->
                        <xsl:apply-templates select="xform:select[1]/xform:item" mode="matrixHeader"/>
                    </tr>
                    <tr>
                        <td><!-- nothing here --></td>
                        <xsl:apply-templates select="xform:select[1]/xform:item" mode="matrixSelectable"/>
                    </tr>
                    <!-- render matrix' body -->
                    <xsl:apply-templates select="xform:select" mode="matrix" />
                </table>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!-- rendering column headers (measurements) -->
    <xsl:template match="xform:item" mode="matrixHeader">
        <td class="matrixHeader">
            <xsl:value-of select="xform:label/text()"/>
        </td>
    </xsl:template>

    <!-- -->
    <xsl:template match="xform:item" mode="matrixSelectable">
        <xsl:variable name="value" select="xform:value/text()"/>
        <xsl:variable name="name" select="@ref"/>
        <td class="matrixSelectableHeader">
            <input type="checkbox" name="{$name}" value="{$value}" />
        </td>
    </xsl:template>


    <!-- render the first column with parameter names into matrix -->
    <xsl:template match="xform:select" mode="matrix">
        <tr>
            <td><xsl:value-of select="@label" /></td>
            <xsl:apply-templates mode="matrix" />
        </tr>
    </xsl:template>


    <!-- render checkboxes and disable checkboxes for invalid parameter 
         measurements -->
    <xsl:template match="xform:item" mode="matrix">
        <xsl:variable name="value" select="xform:value/text()"/>
        <xsl:variable name="name" select="@ref"/>
        <td class="matrixContent">
            <xsl:choose>
            <xsl:when test="@disabled = 'true'">
                <img src="./images/delete.png"/>
            </xsl:when>
            <xsl:otherwise>
                <img src="./images/tick.png"/>
            </xsl:otherwise>
            </xsl:choose>
        </td>
    </xsl:template>


    <xsl:template match="xform:input">
        <xsl:variable name="inputValue" select="xform:value"/>
        <xsl:variable name="inputName" select="@ref"/>
        <xsl:variable name="label" select="xform:label"/>
        
        <!-- TODO: Remove this when we have the GIS interface. (slt) --> 
        <xsl:choose>
            <xsl:when test="$inputName = 'mesh_linestring'">
                <a href="javascript:copy_demo_wkt_line();"><xsl:value-of select="$example-linestring"/>:</a><br/>
            </xsl:when>
            <xsl:when test="$inputName = 'mesh_polygon'">
                <a href="javascript:copy_demo_wkt_polygon();"><xsl:value-of select="$example-polygon"/>:</a><br/>
            </xsl:when>
        </xsl:choose>

        <tr>
            <xsl:choose>
                <xsl:when test="$label != ''">
                    <td class="parameter"><xsl:value-of select="$label"/>:</td>
               </xsl:when>
            </xsl:choose>

            <td>
                <input type="text" id="{$inputName}" name="{$inputName}" value="{$inputValue}" /><br/>
            </td>
        </tr>
    </xsl:template>


    <xsl:template match="xform:label">
        <!-- do nothing here -->
    </xsl:template>

</xsl:stylesheet>

http://dive4elements.wald.intevation.org