bug 1800 : Andrew needed ADL pages to use same velocity layout as non-ADL pages, for consistent look and feel. However, where possible ADL pages should use a blank velocity layout so that page layout can be specified in the ADL. Made the layout (and also area and rescue) configurable via XSL parameters; default behavious is still to assume a blank layout.

This commit is contained in:
sb 2008-04-17 15:04:15 +00:00
parent 1ff56f3dd0
commit c480c2d41e
2 changed files with 755 additions and 551 deletions

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes Transform ADL into (partial) controller classes
$Author: sb $ $Author: sb $
$Revision: 1.18 $ $Revision: 1.19 $
$Date: 2008-04-08 15:05:36 $ $Date: 2008-04-17 15:04:15 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -48,6 +48,13 @@
--> -->
<xsl:param name="abstract-key-name-convention" select="Id"/> <xsl:param name="abstract-key-name-convention" select="Id"/>
<!-- bug 1800 : the name of the Velocity layout to use -->
<xsl:param name="layout-name" select="adl-default-layout"/>
<!-- bug 1800 : the name of the Velocity rescue view to use -->
<xsl:param name="rescue-name" select="adl-default-rescue"/>
<!-- bug 1800 : the name of the area (i.e. URL path part) to use -->
<xsl:param name="area-name" select="auto"/>
<xsl:template match="adl:application"> <xsl:template match="adl:application">
<xsl:call-template name="collection-factory"/> <xsl:call-template name="collection-factory"/>
<xsl:apply-templates select="adl:entity"/> <xsl:apply-templates select="adl:entity"/>
@ -64,7 +71,7 @@
// //
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s // Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using // Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.19 $', 10)"/>
// //
// This file is automatically generated; DO NOT EDIT IT. // This file is automatically generated; DO NOT EDIT IT.
// //
@ -121,7 +128,7 @@ namespace <xsl:value-of select="$controllerns"/> {
// //
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s // Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using // Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.19 $', 10)"/>
// //
// This file is automatically generated; DO NOT EDIT IT. // This file is automatically generated; DO NOT EDIT IT.
// //
@ -157,8 +164,8 @@ namespace <xsl:value-of select="$controllerns"/> {
/// ///
/// DO NOT EDIT THIS FILE! /// DO NOT EDIT THIS FILE!
/// &lt;/summary&gt; /// &lt;/summary&gt;
[ Layout("empty"), Rescue("generalerror"), [ Layout("<xsl:value-of select="$layout-name"/>"), Rescue("<xsl:value-of select="$rescue-name"/>"),
ControllerDetails("<xsl:value-of select="@name"/>", Area = "auto")] ControllerDetails("<xsl:value-of select="@name"/>", Area = "<xsl:value-of select="$area-name"/>")]
public partial class <xsl:value-of select="@name"/>Controller : <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> { public partial class <xsl:value-of select="@name"/>Controller : <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> {
<xsl:if test="adl:form"> <xsl:if test="adl:form">

View file

@ -12,8 +12,8 @@
Transform ADL into velocity view templates Transform ADL into velocity view templates
$Author: sb $ $Author: sb $
$Revision: 1.12 $ $Revision: 1.13 $
$Date: 2008-03-19 15:37:48 $ $Date: 2008-04-17 15:04:15 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! --> Whitespace (or lack of it) is significant! -->
@ -38,16 +38,14 @@
This variable selects which group's permissions should be used when generating widgets --> This variable selects which group's permissions should be used when generating widgets -->
<xsl:param name="permissions-group" select="public"/> <xsl:param name="permissions-group" select="public"/>
<!-- what's all this about? the objective is to get the revision number of the <!-- bug 1800 : the name of the Velocity layout to use. If you are to
transform into the output, /without/ getting that revision number overwritten be able to usefully define content in ADL, then the default ADL layout
with the revision number of the generated file when the generated file is needs to be empty, but if ADL-generated pages are to 'play nice' in
stored to CVS --> largely non-ADL applications, they must be able to use standard layouts.
If you are going to use a non-default layout, however, you're responsible
<xsl:variable name="transform-rev1" for making sure it loads all the scripts, etc, that an ADL controller
select="substring( '$Revision: 1.12 $', 11)"/> expects. -->
<xsl:variable name="transform-revision" <xsl:param name="layout-name" select="adl-default-layout"/>
select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/>
<xsl:template match="adl:application"> <xsl:template match="adl:application">
<output> <output>
@ -62,6 +60,48 @@
<!-- Don't bother generating anything for foreign entities --> <!-- Don't bother generating anything for foreign entities -->
<xsl:template match="adl:entity"> <xsl:template match="adl:entity">
<xsl:choose>
<xsl:when test="$layout-name = 'adl-default-layout'">
<xsl:apply-templates select="." mode="empty-layout"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="non-empty-layout"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- generate views for an entity, assuming a non-empty layout - i.e.
I'm not responsible for head, or for the body tag -->
<xsl:template match="adl:entity" mode="non-empty-layout">
<xsl:variable name="keyfield">
<xsl:choose>
<xsl:when test="adl:key/adl:property">
<xsl:value-of select="adl:key/adl:property[position()=1]/@name"/>
</xsl:when>
<xsl:otherwise>[none]</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:apply-templates select="adl:form" mode="non-empty-layout"/>
<xsl:apply-templates select="adl:list" mode="non-empty-layout"/>
<xsl:text>
</xsl:text>
<xsl:comment>[ cut here: next file '<xsl:value-of select="concat( @name, '/maybedelete.auto.vm')"/>' ]</xsl:comment>
<xsl:text>
</xsl:text>
#set( $title = "<xsl:value-of select="concat( 'Really delete ', @name)"/> $instance.UserIdentifier")
<xsl:comment>
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.13 $', 10)"/>
</xsl:comment>
<xsl:call-template name="maybe-delete">
<xsl:with-param name="entity" select="."/>
</xsl:call-template>
</xsl:template>
<!-- generate views for an entity, assuming a non-empty layout -->
<xsl:template match="adl:entity" mode="empty-layout">
<xsl:variable name="keyfield"> <xsl:variable name="keyfield">
<xsl:choose> <xsl:choose>
<xsl:when test="adl:key/adl:property"> <xsl:when test="adl:key/adl:property">
@ -71,8 +111,8 @@
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<xsl:apply-templates select="adl:form"/> <xsl:apply-templates select="adl:form" mode="empty-layout"/>
<xsl:apply-templates select="adl:list"/> <xsl:apply-templates select="adl:list" mode="empty-layout"/>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:comment> [ cut here: next file '<xsl:value-of select="concat( @name, '/maybedelete.auto.vm')"/>' ] </xsl:comment> <xsl:comment> [ cut here: next file '<xsl:value-of select="concat( @name, '/maybedelete.auto.vm')"/>' ] </xsl:comment>
@ -87,21 +127,25 @@
Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>, Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xslt <xsl:value-of select="$transform-revision"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.13 $', 10)"/>
</xsl:comment> </xsl:comment>
${ShuffleWidgetHelper.InstallScripts()} <xsl:call-template name="install-scripts"/>
${Ajax.InstallScripts()}
${FormHelper.InstallScripts()}
${Validation.InstallScripts()}
${Scriptaculous.InstallScripts()}
${ScriptsHelper.InstallScript( "Behaviour")}
${ScriptsHelper.InstallScript( "Sitewide")}
</head> </head>
<body> <body>
<xsl:call-template name="top"/> <xsl:call-template name="top"/>
<xsl:call-template name="maybe-delete">
<xsl:with-param name="entity" select="."/>
</xsl:call-template>
<xsl:call-template name="foot"/>
</body>
</html>
</xsl:template>
<!-- the guts of the maybe-delete form, whether or not we're using an empty layout -->
<xsl:template name="maybe-delete">
<xsl:param name="entity"/>
<form action="delete.rails" method="post"> <form action="delete.rails" method="post">
<xsl:for-each select="adl:key/adl:property"> <xsl:for-each select="$entity/adl:key/adl:property">
<xsl:choose> <xsl:choose>
<xsl:when test="@type='entity'"> <xsl:when test="@type='entity'">
<xsl:variable name="entityname" select="@entity"/> <xsl:variable name="entityname" select="@entity"/>
@ -144,14 +188,10 @@
</tr> </tr>
</table> </table>
</form> </form>
<xsl:call-template name="foot"/>
</body>
</html>
</xsl:template> </xsl:template>
<!-- layout of forms --> <!-- layout of forms -->
<xsl:template match="adl:form" mode="non-empty-layout">
<xsl:template match="adl:form">
<xsl:variable name="formname" select="@name"/> <xsl:variable name="formname" select="@name"/>
<xsl:variable name="aoran"> <xsl:variable name="aoran">
<xsl:variable name="initial" select="substring( ancestor::adl:entity/@name, 1, 1)"/> <xsl:variable name="initial" select="substring( ancestor::adl:entity/@name, 1, 1)"/>
@ -166,41 +206,23 @@
</xsl:variable> </xsl:variable>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:comment> [ cut here: next file '<xsl:value-of select="concat( ancestor::adl:entity/@name, '/', @name)"/>.auto.vm' ] </xsl:comment> <xsl:comment>[ cut here: next file '<xsl:value-of select="concat( ancestor::adl:entity/@name, '/', @name)"/>.auto.vm' ]</xsl:comment>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<html>
<xsl:comment> <xsl:comment>
#if ( $instance) Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
#set( $title = "<xsl:value-of select="concat( 'Edit ', ' ', ancestor::adl:entity/@name)"/> $instance.UserIdentifier")
#else
#set( $title = "Add a new <xsl:value-of select="ancestor::adl:entity/@name"/>")
#end
</xsl:comment>
<head>
<title>$!title</title>
<xsl:call-template name="head"/>
<xsl:comment>
Application Description Language framework
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL. generated from ADL.
Generated using adl2views.xsl <xsl:value-of select="$transform-revision"/> Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.13 $', 10)"/>
</xsl:comment> </xsl:comment>
${ScriptsHelper.InstallScript( "ShuffleWidget")} #capturefor( title)
#if ( $instance)
${Ajax.InstallScripts()} <xsl:value-of select="concat( 'Edit ', ' ', ancestor::adl:entity/@name)"/> $instance.UserIdentifier
${FormHelper.InstallScripts()} #else
${Validation.InstallScripts()} Add a new <xsl:value-of select="ancestor::adl:entity/@name"/>
${Scriptaculous.InstallScripts()} #end
${DateTimeHelper.InstallScripts()} #end
#capturefor( headextras)
${ScriptsHelper.InstallScript( "Sitewide")}
${ScriptsHelper.InstallScript( "Behaviour")}
${ScriptsHelper.InstallScript( "Epoch")}
${ScriptsHelper.InstallScript( "Panes")}
<script type='text/javascript' language='JavaScript1.2'> <script type='text/javascript' language='JavaScript1.2'>
var panes = new Array( <xsl:for-each select='adl:fieldgroup'> var panes = new Array( <xsl:for-each select='adl:fieldgroup'>
"<xsl:value-of select='@name'/>"<xsl:choose> "<xsl:value-of select='@name'/>"<xsl:choose>
@ -237,12 +259,128 @@
{ {
<xsl:choose> <xsl:choose>
<xsl:when test="@pattern"> <xsl:when test="@pattern">
pattern : new RegExp("<xsl:value-of select="@pattern"/>","gi")<xsl:if test="@size">, pattern : new RegExp("<xsl:value-of select="@pattern"/>","gi")<xsl:if test="@size">
,
maxLength : <xsl:value-of select="@size"/> maxLength : <xsl:value-of select="@size"/>
</xsl:if> </xsl:if>
</xsl:when> </xsl:when>
<xsl:when test="@minimum"> <xsl:when test="@minimum">
min : <xsl:value-of select="@minimum"/><xsl:if test="@maximum">, min : <xsl:value-of select="@minimum"/><xsl:if test="@maximum">
,
max : <xsl:value-of select="@maximum"/>
</xsl:if>
</xsl:when>
</xsl:choose>
});
</xsl:for-each>
</script>
${StylesHelper.InstallStylesheet( "Epoch")}
<script type="text/javascript" language='JavaScript1.2' src="../script/panes.js"></script>
<style type="text/css">
<xsl:for-each select="ancestor::adl:entity//adl:property[@required='true']">
#<xsl:value-of select="concat( 'advice-required-instance_', @name)"/>
{
color: white;
background-color: rgb( 198, 0, 57);
font-style: italic;
}
</xsl:for-each>
</style>
#end
#capturefor(bodyattributes)
onload="performInitialisation()"
#end
<xsl:call-template name="form-content">
<xsl:with-param name="form" select="."/>
</xsl:call-template>
</xsl:template>
<xsl:template match="adl:form" mode="empty-layout">
<xsl:variable name="formname" select="@name"/>
<xsl:variable name="aoran">
<xsl:variable name="initial" select="substring( ancestor::adl:entity/@name, 1, 1)"/>
<xsl:choose>
<xsl:when test="$initial = 'A'">an</xsl:when>
<xsl:when test="$initial = 'E'">an</xsl:when>
<xsl:when test="$initial = 'I'">an</xsl:when>
<xsl:when test="$initial = 'O'">an</xsl:when>
<xsl:when test="$initial = 'U'">an</xsl:when>
<xsl:otherwise>a</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:text>
</xsl:text>
<xsl:comment>[ cut here: next file '<xsl:value-of select="concat( ancestor::adl:entity/@name, '/', @name)"/>.auto.vm' ]</xsl:comment>
<xsl:text>
</xsl:text>
<html>
<xsl:comment>
#if ( $instance)
#set( $title = "<xsl:value-of select="concat( 'Edit ', ' ', ancestor::adl:entity/@name)"/> $instance.UserIdentifier")
#else
#set( $title = "Add a new <xsl:value-of select="ancestor::adl:entity/@name"/>")
#end
</xsl:comment>
<head>
<title>$!title</title>
<xsl:call-template name="head"/>
<xsl:comment>
Application Description Language framework
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.13 $', 10)"/>
</xsl:comment>
<xsl:call-template name="install-scripts"/>
<script type='text/javascript' language='JavaScript1.2'>
var panes = new Array( <xsl:for-each select='adl:fieldgroup'>
"<xsl:value-of select='@name'/>"<xsl:choose>
<xsl:when test="position() = last()"/>
<xsl:otherwise>,</xsl:otherwise>
</xsl:choose>
</xsl:for-each> );
var siteRoot = '$siteRoot';
function performInitialisation()
{
<xsl:for-each select="../property[@type='link']">
document.<xsl:value-of select="$formname"/>.<xsl:value-of select="@name"/>.submitHandler = shuffleSubmitHandler;
</xsl:for-each>
var validator = new Validation('<xsl:value-of select="$formname"/>', {immediate : true, useTitles : true});
<xsl:if test="fieldgroup">
switchtab( '<xsl:value-of select="fieldgroup[1]/@name"/>');
</xsl:if>
}
<xsl:for-each select="//definition">
<xsl:variable name="errormsg">
<xsl:choose>
<xsl:when test="adl:help[@locale=$locale]">
<xsl:apply-templates select="adl:help[@locale=$locale]"/>
</xsl:when>
<xsl:otherwise>
Does not meet the format requirements for <xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Validation.add( '<xsl:value-of select="concat('validate-custom-', @name)"/>',
'<xsl:value-of select="normalize-space( $errormsg)"/>',
{
<xsl:choose>
<xsl:when test="@pattern">
pattern : new RegExp("<xsl:value-of select="@pattern"/>","gi")<xsl:if test="@size">
,
maxLength : <xsl:value-of select="@size"/>
</xsl:if>
</xsl:when>
<xsl:when test="@minimum">
min : <xsl:value-of select="@minimum"/><xsl:if test="@maximum">
,
max : <xsl:value-of select="@maximum"/> max : <xsl:value-of select="@maximum"/>
</xsl:if> </xsl:if>
</xsl:when> </xsl:when>
@ -269,6 +407,19 @@
</head> </head>
<body onload="performInitialisation()"> <body onload="performInitialisation()">
<xsl:call-template name="top"/> <xsl:call-template name="top"/>
<xsl:call-template name="form-content">
<xsl:with-param name="form" select="."/>
</xsl:call-template>
<xsl:call-template name="foot"/>
</body>
</html>
</xsl:template>
<!-- the content of a form, whether or not the layout is empty -->
<xsl:template name="form-content">
<!-- an entity of type form -->
<xsl:param name="form"/>
<xsl:variable name="formname" select="$form/@name"/>
<div class="content"> <div class="content">
#if ( $errors) #if ( $errors)
#if ( $errors.Count != 0) #if ( $errors.Count != 0)
@ -301,8 +452,7 @@
<xsl:attribute name="id"> <xsl:attribute name="id">
<xsl:value-of select="$formname"/> <xsl:value-of select="$formname"/>
</xsl:attribute> </xsl:attribute>
<xsl:variable name="form" select="."/> <xsl:for-each select="$form/ancestor::adl:entity/adl:key/adl:property">
<xsl:for-each select="ancestor::adl:entity/adl:key/adl:property">
<xsl:variable name="keyname" select="@name"/> <xsl:variable name="keyname" select="@name"/>
<xsl:choose> <xsl:choose>
<xsl:when test="$form/adl:field[@property=$keyname]"> <xsl:when test="$form/adl:field[@property=$keyname]">
@ -314,9 +464,9 @@
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:for-each> </xsl:for-each>
<xsl:if test="adl:fieldgroup"> <xsl:if test="$form/adl:fieldgroup">
<div id="tabbar"> <div id="tabbar">
<xsl:for-each select="adl:fieldgroup"> <xsl:for-each select="$form/adl:fieldgroup">
<span class="tab"> <span class="tab">
<xsl:attribute name="id"> <xsl:attribute name="id">
<xsl:value-of select="concat( @name, 'tab')"/> <xsl:value-of select="concat( @name, 'tab')"/>
@ -325,7 +475,9 @@
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="concat( '#', @name, 'anchor')"/> <xsl:value-of select="concat( '#', @name, 'anchor')"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="onclick">switchtab( '<xsl:value-of select="@name"/>'); return false;</xsl:attribute> <xsl:attribute name="onclick">
switchtab( '<xsl:value-of select="@name"/>'); return false;
</xsl:attribute>
<xsl:call-template name="showprompt"> <xsl:call-template name="showprompt">
<xsl:with-param name="fallback" select="@name"/> <xsl:with-param name="fallback" select="@name"/>
</xsl:call-template> </xsl:call-template>
@ -334,15 +486,15 @@
</xsl:for-each> </xsl:for-each>
</div> </div>
</xsl:if> </xsl:if>
<xsl:apply-templates select="adl:fieldgroup"/> <xsl:apply-templates select="$form/adl:fieldgroup"/>
<div class="pane"> <div class="pane">
<table> <table>
<xsl:choose> <xsl:choose>
<xsl:when test="@properties='listed'"> <xsl:when test="@properties='listed'">
<xsl:apply-templates select="adl:field|adl:auxlist|adl:verb"/> <xsl:apply-templates select="$form/adl:field|adl:auxlist|adl:verb"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:apply-templates select="ancestor::adl:entity/adl:property"/> <xsl:apply-templates select="$form/ancestor::adl:entity/adl:property"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<tr class="actionSafe"> <tr class="actionSafe">
@ -374,9 +526,6 @@
</div> </div>
</form> </form>
</div> </div>
<xsl:call-template name="foot"/>
</body>
</html>
</xsl:template> </xsl:template>
<xsl:template match="adl:fieldgroup"> <xsl:template match="adl:fieldgroup">
@ -1097,12 +1246,42 @@
</xsl:template> </xsl:template>
<!-- layout of lists --> <!-- layout of lists -->
<!-- layout of a list assuming a non-empty layout -->
<xsl:template match="adl:list" mode="non-empty-layout">
<xsl:text>
</xsl:text>
<xsl:comment>[ cut here: next file '<xsl:value-of select="concat( ../@name, '/', @name)"/>.auto.vm' ]</xsl:comment>
<xsl:text>
</xsl:text>
<xsl:variable name="withpluralsuffix">
<!-- English-laguage syntactic sugar of entity name -->
<xsl:choose>
<xsl:when test="../@name='Person'">People</xsl:when>
<xsl:when test="starts-with( substring(../@name, string-length(../@name) ), 's')">
<xsl:value-of select="../@name"/>es
</xsl:when>
<xsl:when test="starts-with( substring(../@name, string-length(../@name) ), 'y')">
<xsl:value-of select="substring( ../@name, 0, string-length(../@name) )"/>ies
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="../@name"/>s
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
#capturefor( title)
<xsl:value-of select="normalize-space( concat( 'List ', $withpluralsuffix))"/>
#end
<xsl:call-template name="list">
<xsl:with-param name="list" select="."/>
</xsl:call-template>
</xsl:template>
<xsl:template match="adl:list"> <!-- layout of a list assuming an empty layout -->
<xsl:template match="adl:list" mode="empty-layout">
<xsl:variable name="action" select="@onselect"/> <xsl:variable name="action" select="@onselect"/>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:comment> [ cut here: next file '<xsl:value-of select="concat( ../@name, '/', @name)"/>.auto.vm' ] </xsl:comment> <xsl:comment>[ cut here: next file '<xsl:value-of select="concat( ../@name, '/', @name)"/>.auto.vm' ]</xsl:comment>
<xsl:text> <xsl:text>
</xsl:text> </xsl:text>
<xsl:variable name="withpluralsuffix"> <xsl:variable name="withpluralsuffix">
@ -1129,22 +1308,25 @@
Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>, Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL. generated from ADL.
Generated using adl2listview.xsl <xsl:value-of select="$transform-revision"/> Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.13 $', 10)"/>
</xsl:comment> </xsl:comment>
${Ajax.InstallScripts()} <xsl:call-template name="install-scripts"/>
${FormHelper.InstallScripts()}
${Validation.InstallScripts()}
${Scriptaculous.InstallScripts()}
${DateTimeHelper.InstallScripts()}
${ScriptsHelper.InstallScript( "Behaviour")}
${ScriptsHelper.InstallScript( "Sitewide")}
</head> </head>
<body> <body>
<xsl:call-template name="top"/> <xsl:call-template name="top"/>
<xsl:call-template name="list">
<xsl:with-param name="list" select="."/>
</xsl:call-template>
<xsl:call-template name="foot"/>
</body>
</html>
</xsl:template>
<!-- layout the content of a list, whether or not the layout is empty -->
<xsl:template name="list">
<!-- an entity of type adl:list -->
<xsl:param name="list"/>
<div class="content"> <div class="content">
<xsl:if test="@name='list'">
<!-- this is a hack. There shouldn't be anything magic about a list named 'list'. <!-- this is a hack. There shouldn't be anything magic about a list named 'list'.
We need lists (and forms) to have some sort of pragma to guide the transformation We need lists (and forms) to have some sort of pragma to guide the transformation
process --> process -->
@ -1168,7 +1350,7 @@
#if($instances.HasLast) $PaginationHelper.CreatePageLink( $instances.LastIndex, "&gt;&gt;" ) #end #if($instances.HasLast) $PaginationHelper.CreatePageLink( $instances.LastIndex, "&gt;&gt;" ) #end
#if(!$instances.HasLast) &gt;&gt; #end #if(!$instances.HasLast) &gt;&gt; #end
</span> </span>
<xsl:if test="../adl:form"> <xsl:if test="$list/../adl:form">
<span class="add"> <span class="add">
<a> <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
@ -1188,15 +1370,14 @@
</form> </form>
</div --> </div -->
</div> </div>
</xsl:if>
<table> <table>
<xsl:choose> <xsl:choose>
<xsl:when test="@properties='listed'"> <xsl:when test="$list/@properties='listed'">
<tr> <tr>
<xsl:for-each select="adl:field"> <xsl:for-each select="$list/adl:field">
<th> <th>
<xsl:variable name="pname" select="@property"/> <xsl:variable name="pname" select="@property"/>
<xsl:variable name="property" select="ancestor::adl:entity//adl:property[@name=$pname]"/> <xsl:variable name="property" select="$list/ancestor::adl:entity//adl:property[@name=$pname]"/>
<xsl:choose> <xsl:choose>
<xsl:when test="$property/adl:prompt[@locale=$locale]"> <xsl:when test="$property/adl:prompt[@locale=$locale]">
<xsl:value-of select="$property/adl:prompt[@locale=$locale]/@prompt"/> <xsl:value-of select="$property/adl:prompt[@locale=$locale]/@prompt"/>
@ -1207,7 +1388,7 @@
</xsl:choose> </xsl:choose>
</th> </th>
</xsl:for-each> </xsl:for-each>
<xsl:for-each select="ancestor::adl:entity/adl:form"> <xsl:for-each select="$list/ancestor::adl:entity/adl:form">
<th>-</th> <th>-</th>
</xsl:for-each> </xsl:for-each>
</tr> </tr>
@ -1218,21 +1399,21 @@
#set( $oddity = "odd") #set( $oddity = "odd")
#end #end
<tr class="$oddity"> <tr class="$oddity">
<xsl:for-each select="adl:field"> <xsl:for-each select="$list/adl:field">
<td> <td>
<xsl:variable name="prop" select="@property"/> <xsl:variable name="prop" select="@property"/>
<xsl:choose> <xsl:choose>
<xsl:when test="ancestor::adl:entity//adl:property[@name=$prop]/@type = 'date'"> <xsl:when test="$list/ancestor::adl:entity//adl:property[@name=$prop]/@type = 'date'">
#if ( $instance.<xsl:value-of select="@property"/>) #if ( $instance.<xsl:value-of select="@property"/>)
$instance.<xsl:value-of select="@property"/>.ToString( 'd') $instance.<xsl:value-of select="@property"/>.ToString( 'd')
#end #end
</xsl:when> </xsl:when>
<xsl:when test="ancestor::adl:entity//adl:property[@name=$prop]/@type='message'"> <xsl:when test="$list/ancestor::adl:entity//adl:property[@name=$prop]/@type='message'">
#if ( $instance.<xsl:value-of select="$prop"/>) #if ( $instance.<xsl:value-of select="$prop"/>)
$t.Msg( $instance.<xsl:value-of select="$prop"/>) $t.Msg( $instance.<xsl:value-of select="$prop"/>)
#end #end
</xsl:when> </xsl:when>
<xsl:when test="ancestor::adl:entity//adl:property[@name=$prop]/@type='entity'"> <xsl:when test="$list/ancestor::adl:entity//adl:property[@name=$prop]/@type='entity'">
#if( $instance.<xsl:value-of select="$prop"/>) #if( $instance.<xsl:value-of select="$prop"/>)
$instance.<xsl:value-of select="$prop"/>.UserIdentifier $instance.<xsl:value-of select="$prop"/>.UserIdentifier
#end #end
@ -1246,7 +1427,7 @@
<xsl:variable name="keys"> <xsl:variable name="keys">
<!-- assemble keys in a Velocity-friendly format, then splice it into <!-- assemble keys in a Velocity-friendly format, then splice it into
the HREF below --> the HREF below -->
<xsl:for-each select="ancestor::adl:entity/adl:key/adl:property"> <xsl:for-each select="$list/ancestor::adl:entity/adl:key/adl:property">
<xsl:variable name="sep"> <xsl:variable name="sep">
<xsl:choose> <xsl:choose>
<xsl:when test="position()=1">?</xsl:when> <xsl:when test="position()=1">?</xsl:when>
@ -1263,7 +1444,7 @@
</xsl:choose> </xsl:choose>
</xsl:for-each> </xsl:for-each>
</xsl:variable> </xsl:variable>
<xsl:for-each select="ancestor::adl:entity/adl:form"> <xsl:for-each select="$list/ancestor::adl:entity/adl:form">
<!-- by default create a link to each form declared for the entity. <!-- by default create a link to each form declared for the entity.
We probably need a means of overriding this --> We probably need a means of overriding this -->
<td> <td>
@ -1277,11 +1458,12 @@
</xsl:for-each> </xsl:for-each>
</tr> </tr>
#end <!-- of iteration foreach( $instance in $instances) --> #end <!-- of iteration foreach( $instance in $instances) -->
</xsl:when> <!-- close of @properties='listed ' --> </xsl:when>
<!-- close of @properties='listed ' -->
<xsl:otherwise> <xsl:otherwise>
<!-- properties are not 'listed' --> <!-- properties are not 'listed' -->
<tr> <tr>
<xsl:for-each select="ancestor::adl:entity//adl:property[@distinct='user' and not( @type='link' or @type='list')]"> <xsl:for-each select="$list/ancestor::adl:entity//adl:property[@distinct='user' and not( @type='link' or @type='list')]">
<th> <th>
<xsl:choose> <xsl:choose>
<xsl:when test="adl:prompt[@locale=$locale]"> <xsl:when test="adl:prompt[@locale=$locale]">
@ -1293,7 +1475,7 @@
</xsl:choose> </xsl:choose>
</th> </th>
</xsl:for-each> </xsl:for-each>
<xsl:for-each select="ancestor::adl:entity/adl:form"> <xsl:for-each select="$list/ancestor::adl:entity/adl:form">
<th>-</th> <th>-</th>
</xsl:for-each> </xsl:for-each>
</tr> </tr>
@ -1304,7 +1486,7 @@
#set( $oddity = "odd") #set( $oddity = "odd")
#end #end
<tr class="$oddity"> <tr class="$oddity">
<xsl:for-each select="ancestor::adl:entity//adl:property[@distinct='user']"> <xsl:for-each select="$list/ancestor::adl:entity//adl:property[@distinct='user']">
<td> <td>
<xsl:choose> <xsl:choose>
<xsl:when test="@type = 'date'"> <xsl:when test="@type = 'date'">
@ -1331,7 +1513,7 @@
<xsl:variable name="keys"> <xsl:variable name="keys">
<!-- assemble keys in a Velocity-friendly format, then splice it into <!-- assemble keys in a Velocity-friendly format, then splice it into
the HREF below --> the HREF below -->
<xsl:for-each select="ancestor::adl:entity/adl:key/adl:property"> <xsl:for-each select="$list/ancestor::adl:entity/adl:key/adl:property">
<xsl:variable name="sep"> <xsl:variable name="sep">
<xsl:choose> <xsl:choose>
<xsl:when test="position()=1">?</xsl:when> <xsl:when test="position()=1">?</xsl:when>
@ -1348,7 +1530,7 @@
</xsl:choose> </xsl:choose>
</xsl:for-each> </xsl:for-each>
</xsl:variable> </xsl:variable>
<xsl:for-each select="ancestor::adl:entity/adl:form"> <xsl:for-each select="$list/ancestor::adl:entity/adl:form">
<!-- by default create a link to each form declared for the entity. <!-- by default create a link to each form declared for the entity.
We probably need a means of overriding this --> We probably need a means of overriding this -->
<td> <td>
@ -1366,15 +1548,30 @@
</xsl:choose> </xsl:choose>
</table> </table>
</div> </div>
<xsl:call-template name="foot"/>
</body>
</html>
</xsl:template> </xsl:template>
<!-- overall page layout --> <!-- overall page layout -->
<xsl:template match="adl:content"/> <xsl:template match="adl:content"/>
<!-- assuming an empty layout, install all the standard scripts
which an ADL page may need -->
<xsl:template name="install-scripts">
${ScriptsHelper.InstallScript( "ShuffleWidget")}
${Ajax.InstallScripts()}
${FormHelper.InstallScripts()}
${Validation.InstallScripts()}
${Scriptaculous.InstallScripts()}
${DateTimeHelper.InstallScripts()}
${ScriptsHelper.InstallScript( "Sitewide")}
${ScriptsHelper.InstallScript( "Behaviour")}
${ScriptsHelper.InstallScript( "Epoch")}
${ScriptsHelper.InstallScript( "Panes")}
</xsl:template>
<xsl:template name="head"> <xsl:template name="head">
<xsl:choose> <xsl:choose>
<xsl:when test="adl:head"> <xsl:when test="adl:head">